@@ -8,6 +8,7 @@ import * as globalStore from '../src';
88import Middleware from '../src/Middleware' ;
99import { STORE_KEY } from '../src/StoreDomain' ;
1010import AsyncStoreAdapter from '../src/AsyncStoreAdapter' ;
11+ import { getActiveDomain } from '../src/impl/domain' ;
1112
1213describe ( 'store: [adapter=DOMAIN]' , ( ) => {
1314 const adapter = AsyncStoreAdapter . DOMAIN ;
@@ -503,6 +504,47 @@ describe('store: [adapter=DOMAIN]', () => {
503504 globalStore . reset ( ) ;
504505
505506 expect ( globalStore . isInitialized ( ) ) . to . equal ( false ) ;
507+
508+ const activeDomain = getActiveDomain ( ) ;
509+ expect ( activeDomain [ STORE_KEY ] ) . to . equal ( null ) ;
510+ } ) ;
511+ } ) ;
512+
513+ describe ( 'del():' , ( ) => {
514+ it ( 'should delete a key from the store.' , ( done ) => {
515+ const callback = ( ) => {
516+ globalStore . set ( { foo : 'foo' , bar : 'bar' } ) ;
517+
518+ expect ( globalStore . get ( 'foo' ) ) . to . equal ( 'foo' ) ;
519+ expect ( globalStore . get ( 'bar' ) ) . to . equal ( 'bar' ) ;
520+
521+ globalStore . del ( 'foo' ) ;
522+
523+ expect ( globalStore . get ( 'foo' ) ) . to . equal ( undefined ) ;
524+ expect ( globalStore . get ( 'bar' ) ) . to . equal ( 'bar' ) ;
525+
526+ done ( ) ;
527+ } ;
528+
529+ globalStore . initialize ( adapter ) ( callback ) ;
530+ } ) ;
531+
532+ it ( 'should do nothing if the key does not exist.' , ( done ) => {
533+ const callback = ( ) => {
534+ globalStore . set ( { foo : 'foo' , bar : 'bar' } ) ;
535+
536+ expect ( globalStore . get ( 'foo' ) ) . to . equal ( 'foo' ) ;
537+ expect ( globalStore . get ( 'bar' ) ) . to . equal ( 'bar' ) ;
538+
539+ globalStore . del ( 'baz' ) ;
540+
541+ expect ( globalStore . get ( 'foo' ) ) . to . equal ( 'foo' ) ;
542+ expect ( globalStore . get ( 'bar' ) ) . to . equal ( 'bar' ) ;
543+
544+ done ( ) ;
545+ } ;
546+
547+ globalStore . initialize ( adapter ) ( callback ) ;
506548 } ) ;
507549 } ) ;
508550
0 commit comments