@@ -54,6 +54,27 @@ class ManifestValidationTest : FunSpec({
54
54
),
55
55
)
56
56
}
57
+
58
+ test("list type") {
59
+ // given
60
+ val manifest = Manifest (
61
+ typingSpec = expectedTypingSpec,
62
+ inputs = mapOf(
63
+ "list-input" to ApiItem (type = "list", separator = "\n"),
64
+ ),
65
+ )
66
+
67
+ // when
68
+ val result = manifest.validate()
69
+
70
+ // then
71
+ result shouldBe ActionValidationResult (
72
+ overallResult = ItemValidationResult .Valid ,
73
+ inputs = mapOf(
74
+ "list-input" to ItemValidationResult .Valid ,
75
+ ),
76
+ )
77
+ }
57
78
}
58
79
59
80
context("failure cases") {
@@ -181,6 +202,54 @@ class ManifestValidationTest : FunSpec({
181
202
)
182
203
}
183
204
205
+ test("primitive types with 'separator' attribute") {
206
+ // given
207
+ val manifest = Manifest (
208
+ typingSpec = expectedTypingSpec,
209
+ inputs = mapOf(
210
+ "string-input" to ApiItem (type = "string", separator = ","),
211
+ "boolean-input" to ApiItem (type = "boolean", separator = ","),
212
+ "integer-input" to ApiItem (type = "integer", separator = ","),
213
+ "float-input" to ApiItem (type = "float", separator = ","),
214
+ ),
215
+ )
216
+
217
+ // when
218
+ val result = manifest.validate()
219
+
220
+ // then
221
+ result shouldBe ActionValidationResult (
222
+ overallResult = ItemValidationResult .Invalid ("Some typing is invalid."),
223
+ inputs = mapOf(
224
+ "string-input" to ItemValidationResult .Invalid ("'separator' is not allowed for this type."),
225
+ "boolean-input" to ItemValidationResult .Invalid ("'separator' is not allowed for this type."),
226
+ "integer-input" to ItemValidationResult .Invalid ("'separator' is not allowed for this type."),
227
+ "float-input" to ItemValidationResult .Invalid ("'separator' is not allowed for this type."),
228
+ ),
229
+ )
230
+ }
231
+
232
+ test("enum type with 'separator' attribute") {
233
+ // given
234
+ val manifest = Manifest (
235
+ typingSpec = expectedTypingSpec,
236
+ inputs = mapOf(
237
+ "enum-input" to ApiItem (type = "enum", allowedValues = listOf("foo", "bar", "baz"), separator = ","),
238
+ ),
239
+ )
240
+
241
+ // when
242
+ val result = manifest.validate()
243
+
244
+ // then
245
+ result shouldBe ActionValidationResult (
246
+ overallResult = ItemValidationResult .Invalid ("Some typing is invalid."),
247
+ inputs = mapOf(
248
+ "enum-input" to ItemValidationResult .Invalid ("'separator' is not allowed for this type."),
249
+ ),
250
+ )
251
+ }
252
+
184
253
test("enum type without 'allowedValues' attribute") {
185
254
// given
186
255
val manifest = Manifest (
@@ -222,5 +291,47 @@ class ManifestValidationTest : FunSpec({
222
291
),
223
292
)
224
293
}
294
+
295
+ test("list type without 'separator' attribute") {
296
+ // given
297
+ val manifest = Manifest (
298
+ typingSpec = expectedTypingSpec,
299
+ inputs = mapOf(
300
+ "list-input" to ApiItem (type = "list"),
301
+ ),
302
+ )
303
+
304
+ // when
305
+ val result = manifest.validate()
306
+
307
+ // then
308
+ result shouldBe ActionValidationResult (
309
+ overallResult = ItemValidationResult .Invalid ("Some typing is invalid."),
310
+ inputs = mapOf(
311
+ "list-input" to ItemValidationResult .Invalid ("Separator must be specified."),
312
+ ),
313
+ )
314
+ }
315
+
316
+ test("list type with 'allowedValues' attribute") {
317
+ // given
318
+ val manifest = Manifest (
319
+ typingSpec = expectedTypingSpec,
320
+ inputs = mapOf(
321
+ "list-input" to ApiItem (type = "list", separator = "\n", allowedValues = listOf("foo", "bar")),
322
+ ),
323
+ )
324
+
325
+ // when
326
+ val result = manifest.validate()
327
+
328
+ // then
329
+ result shouldBe ActionValidationResult (
330
+ overallResult = ItemValidationResult .Invalid ("Some typing is invalid."),
331
+ inputs = mapOf(
332
+ "list-input" to ItemValidationResult .Invalid ("'allowedValues' is not allowed for this type."),
333
+ ),
334
+ )
335
+ }
225
336
}
226
337
})
0 commit comments