File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
packages/compass-crud/src/stores Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -456,6 +456,7 @@ describe('store', function () {
456456 } ,
457457 actions : actions ,
458458 namespace : 'compass-crud.test' ,
459+ noRefreshOnConfigure : true ,
459460 } ) ;
460461 } ) ;
461462
@@ -505,6 +506,29 @@ describe('store', function () {
505506 } ) ;
506507 } ) ;
507508
509+ context ( 'when the count is null' , function ( ) {
510+ const doc = { _id : null , name : 'Depeche Mode' } ;
511+ const hadronDoc = new HadronDocument ( doc ) ;
512+
513+ beforeEach ( function ( ) {
514+ store . state . docs = [ hadronDoc ] ;
515+ store . state . count = null ;
516+ store . state . end = 1 ;
517+ } ) ;
518+
519+ it ( 'keeps the count as null after the delete' , async function ( ) {
520+ const listener = waitForState ( store , ( state ) => {
521+ expect ( state . docs . length ) . to . equal ( 0 ) ;
522+ expect ( state . count ) . to . equal ( null ) ;
523+ expect ( state . end ) . to . equal ( 0 ) ;
524+ } ) ;
525+
526+ store . removeDocument ( hadronDoc ) ;
527+
528+ await listener ;
529+ } ) ;
530+ } ) ;
531+
508532 context ( 'when the deletion errors' , function ( ) {
509533 const doc = { _id : 'testing' , name : 'Depeche Mode' } ;
510534 const hadronDoc = new HadronDocument ( doc ) ;
Original file line number Diff line number Diff line change @@ -540,7 +540,7 @@ class CrudStoreImpl
540540 const index = this . findDocumentIndex ( doc ) ;
541541 this . state . docs ?. splice ( index , 1 ) ;
542542 this . setState ( {
543- count : ( this . state . count ?? 1 ) - 1 ,
543+ count : this . state . count === null ? null : this . state . count - 1 ,
544544 end : Math . max ( this . state . end - 1 , 0 ) ,
545545 } ) ;
546546 }
You can’t perform that action at this time.
0 commit comments