-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52c9659
commit 9b0ce0e
Showing
3 changed files
with
47 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
client/src/test/scala/slack/api/models/SerializationSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package slack.api.models | ||
|
||
import com.github.dapperware.slack.models.{ InputBlockElement, PlainTextInput } | ||
import io.circe.syntax.EncoderOps | ||
import zio.random.Random | ||
import zio.test.Assertion._ | ||
import zio.test.magnolia.DeriveGen | ||
import zio.test._ | ||
|
||
object SerializationSpec extends DefaultRunnableSpec { | ||
|
||
implicit val blockInputGen: Gen[Sized with Random, PlainTextInput] = { | ||
implicit val alphaCharGen: DeriveGen[String] = DeriveGen.instance(Gen.string(Gen.alphaNumericChar)) | ||
DeriveGen[PlainTextInput] | ||
} | ||
|
||
override def spec = suite("Serialization")( | ||
suite("PlainTextInput")( | ||
testM("reads what it writes")(check(blockInputGen) { blockInput => | ||
val encoded = (blockInput: InputBlockElement).asJson | ||
val decoded = encoded.as[InputBlockElement] | ||
assert(decoded)(isRight(equalTo(blockInput))) && assert(encoded.hcursor.downField("type").as[String])( | ||
isRight(equalTo("plain_text_input")) | ||
) | ||
}) | ||
) | ||
) | ||
} |