Permalink
Browse files

Added another test

  • Loading branch information...
tlangs authored and travisbrown committed Nov 30, 2017
1 parent e80a85c commit 2579c228b29c3e2454d804a4e5837e887ffe80c4
@@ -73,7 +73,7 @@ class ConfiguredAutoDerivedSuite extends CirceSuite {
}
}
"Configuration#transformConstructorNames" should "support constructor name transformation" in forAll { (f: String, a: Int, b: Double) =>
"Configuration#transformConstructorNames" should "support constructor name transformation with snake_case" in forAll { (f: String, a: Int, b: Double) =>
implicit val snakeCaseConfig: Configuration = Configuration.default.withDiscriminator("type").withSnakeCaseConstructorNames
val foo: ConfigExampleBase = ConfigExampleFoo(f, a, b)
@@ -83,6 +83,16 @@ class ConfiguredAutoDerivedSuite extends CirceSuite {
assert(Decoder[ConfigExampleBase].decodeJson(json) === Right(foo))
}
"Configuration#transformConstructorNames" should "support constructor name transformation with kebab-case" in forAll { (f: String, a: Int, b: Double) =>
implicit val kebabCaseConfig: Configuration = Configuration.default.withDiscriminator("type").withKebabCaseConstructorNames
val foo: ConfigExampleBase = ConfigExampleFoo(f, a, b)
val json = json"""{ "type": "config-example-foo", "thisIsAField": $f, "a": $a, "b": $b}"""
assert(Encoder[ConfigExampleBase].apply(foo) === json)
assert(Decoder[ConfigExampleBase].decodeJson(json) === Right(foo))
}
"Configuration options" should "work together" in forAll { (f: String, b: Double) =>
implicit val customConfig: Configuration =
Configuration.default.withSnakeCaseMemberNames.withDefaults.withDiscriminator("type")

0 comments on commit 2579c22

Please sign in to comment.