@@ -248,14 +248,59 @@ test 'Throw an error when the required list property get null.', ->
248
248
expect (-> property .toJs null ).toThrow exceptions .ValueRequiredError
249
249
expect (-> property .toDb property : null ).toThrow exceptions .ValueRequiredError
250
250
251
- test ' Convert the value of the list property to the list.' , ->
251
+ test ' Convert the value of the string list property to the list.' , ->
252
252
property = new properties.ListProperty
253
253
itemClass : properties .StringProperty
254
254
property .propertyName = ' property'
255
255
instance =
256
- property : [' item' ]
257
- expect (property .toJs ([' item' ])).toEqual [' item' ]
258
- expect (property .toDb (instance)).toEqual [' item' ]
256
+ property : [' itemA' , ' itemB' ]
257
+ expect (property .toJs ([' itemA' , ' itemB' ])).toEqual [' itemA' , ' itemB' ]
258
+ expect (property .toDb (instance)).toEqual [' itemA' , ' itemB' ]
259
+
260
+ test ' Convert the value of the integer list property to the list.' , ->
261
+ property = new properties.ListProperty
262
+ itemClass : properties .IntegerProperty
263
+ property .propertyName = ' property'
264
+ instance =
265
+ property : [2 , 3 ]
266
+ expect (property .toJs ([2 , 3 ])).toEqual [2 , 3 ]
267
+ expect (property .toDb (instance)).toEqual [2 , 3 ]
268
+
269
+ test ' Convert the value of the float list property to the list.' , ->
270
+ property = new properties.ListProperty
271
+ itemClass : properties .FloatProperty
272
+ property .propertyName = ' property'
273
+ instance =
274
+ property : [3.1 , 3.3 ]
275
+ expect (property .toJs ([3.1 , 3.3 ])).toEqual [3.1 , 3.3 ]
276
+ expect (property .toDb (instance)).toEqual [3.1 , 3.3 ]
277
+
278
+ test ' Convert the value of the boolean list property to the list.' , ->
279
+ property = new properties.ListProperty
280
+ itemClass : properties .BooleanProperty
281
+ property .propertyName = ' property'
282
+ instance =
283
+ property : [yes , no ]
284
+ expect (property .toJs ([yes , no ])).toEqual [yes , no ]
285
+ expect (property .toDb (instance)).toEqual [yes , no ]
286
+
287
+ test ' Convert the value of the date list property to the list.' , ->
288
+ property = new properties.ListProperty
289
+ itemClass : properties .DateProperty
290
+ property .propertyName = ' property'
291
+ instance =
292
+ property : [new Date (' 2019-01-29T06:01:00.000Z' )]
293
+ expect (property .toJs ([' 2019-01-29T06:01:00.000Z' ])).toEqual [new Date (' 2019-01-29T06:01:00.000Z' )]
294
+ expect (property .toDb (instance)).toEqual [' 2019-01-29T06:01:00.000Z' ]
295
+
296
+ test ' Direct pass the value of object list properties to the list.' , ->
297
+ property = new properties.ListProperty
298
+ itemClass : properties .ObjectProperty
299
+ property .propertyName = ' property'
300
+ instance =
301
+ property : [{a : yes }]
302
+ expect (property .toJs ([{a : yes }])).toEqual [{a : yes }]
303
+ expect (property .toDb (instance)).toEqual [{a : yes }]
259
304
260
305
261
306
# Object property
0 commit comments