@@ -346,7 +346,7 @@ describe('S C H E M A F O R M', () => {
346
346
} ) ;
347
347
} ) ;
348
348
349
- test ( 'should reset initial values' , ( ) => {
349
+ test ( 'should reset initial values' , ( done ) => {
350
350
const preventDefault = jest . fn ( ) ;
351
351
const stopPropagation = jest . fn ( ) ;
352
352
const values = {
@@ -358,48 +358,53 @@ describe('S C H E M A F O R M', () => {
358
358
multiselect : [ 'a' ] ,
359
359
} ;
360
360
component . values = deepClone ( values ) ;
361
+ component . updateComplete . then ( ( ) => {
362
+ const pathOperatorControl = component . getControl ( 'path-operator' ) ;
363
+
364
+ expect ( pathOperatorControl ) . not . toBeNull ( ) ;
365
+ pathOperatorControl . _onInput ( {
366
+ preventDefault,
367
+ stopPropagation,
368
+ target : { id : 'path-operator.path' } ,
369
+ detail : '/updated-path' ,
370
+ } ) ;
361
371
362
- const pathOperatorControl = component . getControl ( 'path-operator' ) ;
363
- expect ( pathOperatorControl ) . not . toBeNull ( ) ;
364
- pathOperatorControl . _onInput ( {
365
- preventDefault,
366
- stopPropagation,
367
- target : { id : 'path-operator.path' } ,
368
- detail : '/updated-path' ,
369
- } ) ;
370
-
371
- const timeToLiveSeconds = component . getControl ( 'timeToLiveSeconds' ) ;
372
- expect ( timeToLiveSeconds ) . not . toBeNull ( ) ;
373
- timeToLiveSeconds . _onInput ( {
374
- preventDefault,
375
- stopPropagation,
376
- target : { id : 'timeToLiveSeconds' } ,
377
- detail : 12 ,
378
- } ) ;
372
+ const timeToLiveSeconds = component . getControl ( 'timeToLiveSeconds' ) ;
373
+ expect ( timeToLiveSeconds ) . not . toBeNull ( ) ;
374
+ timeToLiveSeconds . _onInput ( {
375
+ preventDefault,
376
+ stopPropagation,
377
+ target : { id : 'timeToLiveSeconds' } ,
378
+ detail : 12 ,
379
+ } ) ;
379
380
380
- const multiselect = component . getControl ( 'multiselect' ) ;
381
- multiselect . _onInput ( {
382
- preventDefault,
383
- stopPropagation,
384
- target : { id : 'multiselect' } ,
385
- detail : [ 'a' , 'b' ] ,
386
- } ) ;
381
+ const multiselect = component . getControl ( 'multiselect' ) ;
382
+ multiselect . _onInput ( {
383
+ preventDefault,
384
+ stopPropagation,
385
+ target : { id : 'multiselect' } ,
386
+ detail : [ 'a' , 'b' ] ,
387
+ } ) ;
387
388
388
- expect ( component . values ) . toEqual ( {
389
- 'path-operator' : {
390
- operator : 'STARTS_WITH' ,
391
- path : '/updated-path' ,
392
- } ,
393
- timeToLiveSeconds : 12 ,
394
- multiselect : [ 'a' , 'b' ] ,
395
- } ) ;
389
+ expect ( component . values ) . toEqual ( {
390
+ 'path-operator' : {
391
+ operator : 'STARTS_WITH' ,
392
+ path : '/updated-path' ,
393
+ } ,
394
+ readonly : 'Should not edit my value' ,
395
+ timeToLiveSeconds : 12 ,
396
+ writeonly : 'Should not read my value' ,
397
+ multiselect : [ 'a' , 'b' ] ,
398
+ } ) ;
396
399
397
- component . reset ( ) ;
400
+ component . reset ( ) ;
398
401
399
- expect ( component . values ) . toEqual ( values ) ;
402
+ expect ( component . values ) . toEqual ( values ) ;
403
+ done ( ) ;
404
+ } ) ;
400
405
} ) ;
401
406
402
- test ( 'should remove value with empty string & empty array' , ( ) => {
407
+ test ( 'should remove value with empty string & empty array' , ( done ) => {
403
408
const preventDefault = jest . fn ( ) ;
404
409
const stopPropagation = jest . fn ( ) ;
405
410
const values = {
@@ -412,36 +417,42 @@ describe('S C H E M A F O R M', () => {
412
417
} ;
413
418
component . values = deepClone ( values ) ;
414
419
415
- const pathOperatorControl = component . getControl ( 'path-operator' ) ;
416
- expect ( pathOperatorControl ) . not . toBeNull ( ) ;
417
- pathOperatorControl . _onInput ( {
418
- preventDefault,
419
- stopPropagation,
420
- target : { id : 'path-operator.path' } ,
421
- detail : '' ,
422
- } ) ;
420
+ component . updateComplete . then ( ( ) => {
421
+ const pathOperatorControl = component . getControl ( 'path-operator' ) ;
422
+ expect ( pathOperatorControl ) . not . toBeNull ( ) ;
423
+ pathOperatorControl . _onInput ( {
424
+ preventDefault,
425
+ stopPropagation,
426
+ target : { id : 'path-operator.path' } ,
427
+ detail : '' ,
428
+ } ) ;
423
429
424
- const timeToLiveSeconds = component . getControl ( 'timeToLiveSeconds' ) ;
425
- expect ( timeToLiveSeconds ) . not . toBeNull ( ) ;
426
- timeToLiveSeconds . _onInput ( {
427
- preventDefault,
428
- stopPropagation,
429
- target : { id : 'timeToLiveSeconds' } ,
430
- detail : '' ,
431
- } ) ;
430
+ const timeToLiveSeconds = component . getControl ( 'timeToLiveSeconds' ) ;
431
+ expect ( timeToLiveSeconds ) . not . toBeNull ( ) ;
432
+ timeToLiveSeconds . _onInput ( {
433
+ preventDefault,
434
+ stopPropagation,
435
+ target : { id : 'timeToLiveSeconds' } ,
436
+ detail : '' ,
437
+ } ) ;
432
438
433
- const multiselect = component . getControl ( 'multiselect' ) ;
434
- multiselect . _onInput ( {
435
- preventDefault,
436
- stopPropagation,
437
- target : { id : 'multiselect' } ,
438
- detail : [ ] ,
439
- } ) ;
439
+ const multiselect = component . getControl ( 'multiselect' ) ;
440
+ multiselect . _onInput ( {
441
+ preventDefault,
442
+ stopPropagation,
443
+ target : { id : 'multiselect' } ,
444
+ detail : [ ] ,
445
+ } ) ;
440
446
441
- expect ( component . values ) . toEqual ( {
442
- 'path-operator' : {
443
- operator : 'STARTS_WITH' ,
444
- } ,
447
+ expect ( component . values ) . toEqual ( {
448
+ 'path-operator' : {
449
+ operator : 'STARTS_WITH' ,
450
+ } ,
451
+ readonly : 'Should not edit my value' ,
452
+ writeonly : 'Should not read my value' ,
453
+ } ) ;
454
+
455
+ done ( ) ;
445
456
} ) ;
446
457
} ) ;
447
458
0 commit comments