@@ -21,8 +21,8 @@ const options = {
21
21
service : null
22
22
}
23
23
24
- const { find, count, list, get, getCopyById } = makeServiceGetters ( )
25
- const { addItems } = makeServiceMutations ( )
24
+ const { find, count, list, get, getCopyById, isCreatePendingById , isUpdatePendingById , isPatchPendingById , isRemovePendingById , isPendingById } = makeServiceGetters ( )
25
+ const { addItems, setIdPending , unsetIdPending } = makeServiceMutations ( )
26
26
27
27
describe ( 'Service Module - Getters' , function ( ) {
28
28
beforeEach ( function ( ) {
@@ -403,4 +403,63 @@ describe('Service Module - Getters', function () {
403
403
const total = count ( state , { find } ) ( { query : { } } )
404
404
assert ( total === 3 , 'count is 3' )
405
405
} )
406
+
407
+ it ( 'is*PendingById' , function ( ) {
408
+ const { state } = this
409
+ const getters = { isCreatePendingById, isUpdatePendingById, isPatchPendingById, isRemovePendingById }
410
+
411
+ assert ( isCreatePendingById ( state ) ( 42 ) === false , 'creating status is clear' )
412
+ assert ( isUpdatePendingById ( state ) ( 42 ) === false , 'updating status is clear' )
413
+ assert ( isPatchPendingById ( state ) ( 42 ) === false , 'patching status is clear' )
414
+ assert ( isRemovePendingById ( state ) ( 42 ) === false , 'removing status is clear' )
415
+ assert ( isPendingById ( state , getters ) ( 42 ) , 'any method pending status is clear' )
416
+
417
+ // Create
418
+ setIdPending ( state , { method : 'create' , id : 42 } )
419
+ assert ( isCreatePendingById ( state ) ( 42 ) === true , 'creating status is set' )
420
+ assert ( isPendingById ( state , getters ) ( 42 ) , 'any method pending status is set' )
421
+
422
+ unsetIdPending ( state , { method : 'create' , id : 42 } )
423
+ assert ( isCreatePendingById ( state ) ( 42 ) === false , 'creating status is clear' )
424
+ assert ( isUpdatePendingById ( state ) ( 42 ) === false , 'updating status is clear' )
425
+ assert ( isPatchPendingById ( state ) ( 42 ) === false , 'patching status is clear' )
426
+ assert ( isRemovePendingById ( state ) ( 42 ) === false , 'removing status is clear' )
427
+ assert ( isPendingById ( state , getters ) ( 42 ) , 'any method pending status is clear' )
428
+
429
+ // Update
430
+ setIdPending ( state , { method : 'update' , id : 42 } )
431
+ assert ( isUpdatePendingById ( state ) ( 42 ) === true , 'updating status is set' )
432
+ assert ( isPendingById ( state , getters ) ( 42 ) , 'any method pending status is set' )
433
+
434
+ unsetIdPending ( state , { method : 'update' , id : 42 } )
435
+ assert ( isCreatePendingById ( state ) ( 42 ) === false , 'creating status is clear' )
436
+ assert ( isUpdatePendingById ( state ) ( 42 ) === false , 'updating status is clear' )
437
+ assert ( isPatchPendingById ( state ) ( 42 ) === false , 'patching status is clear' )
438
+ assert ( isRemovePendingById ( state ) ( 42 ) === false , 'removing status is clear' )
439
+ assert ( isPendingById ( state , getters ) ( 42 ) , 'any method pending status is clear' )
440
+
441
+ // Patch
442
+ setIdPending ( state , { method : 'patch' , id : 42 } )
443
+ assert ( isPatchPendingById ( state ) ( 42 ) === true , 'patching status is set' )
444
+ assert ( isPendingById ( state , getters ) ( 42 ) , 'any method pending status is set' )
445
+
446
+ unsetIdPending ( state , { method : 'patch' , id : 42 } )
447
+ assert ( isCreatePendingById ( state ) ( 42 ) === false , 'creating status is clear' )
448
+ assert ( isUpdatePendingById ( state ) ( 42 ) === false , 'updating status is clear' )
449
+ assert ( isPatchPendingById ( state ) ( 42 ) === false , 'patching status is clear' )
450
+ assert ( isRemovePendingById ( state ) ( 42 ) === false , 'removing status is clear' )
451
+ assert ( isPendingById ( state , getters ) ( 42 ) , 'any method pending status is clear' )
452
+
453
+ // Remove
454
+ setIdPending ( state , { method : 'remove' , id : 42 } )
455
+ assert ( isRemovePendingById ( state ) ( 42 ) === true , 'removing status is set' )
456
+ assert ( isPendingById ( state , getters ) ( 42 ) , 'any method pending status is set' )
457
+
458
+ unsetIdPending ( state , { method : 'remove' , id : 42 } )
459
+ assert ( isCreatePendingById ( state ) ( 42 ) === false , 'creating status is clear' )
460
+ assert ( isUpdatePendingById ( state ) ( 42 ) === false , 'updating status is clear' )
461
+ assert ( isPatchPendingById ( state ) ( 42 ) === false , 'patching status is clear' )
462
+ assert ( isRemovePendingById ( state ) ( 42 ) === false , 'removing status is clear' )
463
+ assert ( isPendingById ( state , getters ) ( 42 ) , 'any method pending status is clear' )
464
+ } )
406
465
} )
0 commit comments