@@ -19,6 +19,7 @@ import com.tailrocks.graphql.datetime.DateTimeHelper.createDate
1919import graphql.language.StringValue
2020import graphql.schema.CoercingParseLiteralException
2121import graphql.schema.CoercingParseValueException
22+ import graphql.schema.CoercingSerializeException
2223import io.kotest.assertions.throwables.shouldThrow
2324import io.kotest.core.spec.style.FreeSpec
2425import io.kotest.matchers.shouldBe
@@ -60,36 +61,35 @@ class GraphQLDateTest : FreeSpec({
6061 }
6162 }
6263
63- /*
64-
65- @Unroll
66- def "Date serialize #value into #result (#result.class)"() {
67- expect:
68- new GraphqlDateCoercing().serialize(value) == result
69-
70- where:
71- value | result
72- createDate(2017, 7, 9, 11, 54, 42, 277) | '2017-07-09T11:54:42.277Z'
73- createDate(2017, 7, 9, 13, 14, 45, 947) | '2017-07-09T13:14:45.947Z'
74- createDate(2017, 7, 9, 11, 54, 42) | '2017-07-09T11:54:42Z'
75- createDate(2017, 7, 9) | '2017-07-09T00:00:00Z'
76- }
77-
78- @Unroll
79- def "serialize throws exception for invalid input #value"() {
80- when:
81- new GraphqlDateCoercing().serialize(value)
82- then:
83- thrown(CoercingSerializeException)
84-
85- where:
86- value | _
87- '' | _
88- 'not a date' | _
89- new Object() | _
90- }
64+ " serialize -> success" - {
65+ listOf(
66+ createDate(2017, 7, 9, 11, 54, 42, 277)
67+ to "2017-07-09T11:54:42.277Z",
68+ createDate(2017, 7, 9, 13, 14, 45, 947)
69+ to "2017-07-09T13:14:45.947Z",
70+ createDate(2017, 7, 9, 11, 54, 42)
71+ to "2017-07-09T11:54:42Z",
72+ createDate(2017, 7, 9) to "2017-07-09T00:00:00Z"
73+ ).forEach { (value, result) ->
74+ " serialize $value into $result (${result::class } )" {
75+ GraphqlDateCoercing ().serialize(value) shouldBe result
76+ }
77+ }
78+ }
9179
92- */
80+ " serialize -> fail" - {
81+ listOf(
82+ "",
83+ "not a date",
84+ Object ()
85+ ).forEach { value ->
86+ " serialize throws exception for invalid input: $value " {
87+ shouldThrow<CoercingSerializeException > {
88+ GraphqlDateCoercing ().serialize(value)
89+ }
90+ }
91+ }
92+ }
9393
9494 " parseValue -> success" - {
9595 listOf(
0 commit comments