@@ -73,6 +73,59 @@ describe('getBatchEventProcessor', () => {
7373 } ) ) . toThrow ( 'Invalid event dispatcher' ) ;
7474 } ) ;
7575
76+ it ( 'should throw and error if provided event store is invalid' , ( ) => {
77+ expect ( ( ) => getBatchEventProcessor ( {
78+ eventDispatcher : getMockEventDispatcher ( ) ,
79+ defaultFlushInterval : 10000 ,
80+ defaultBatchSize : 10 ,
81+ eventStore : 'abc' as any ,
82+ } ) ) . toThrow ( 'Invalid event store' ) ;
83+
84+ expect ( ( ) => getBatchEventProcessor ( {
85+ eventDispatcher : getMockEventDispatcher ( ) ,
86+ defaultFlushInterval : 10000 ,
87+ defaultBatchSize : 10 ,
88+ eventStore : 123 as any ,
89+ } ) ) . toThrow ( 'Invalid event store' ) ;
90+
91+ expect ( ( ) => getBatchEventProcessor ( {
92+ eventDispatcher : getMockEventDispatcher ( ) ,
93+ defaultFlushInterval : 10000 ,
94+ defaultBatchSize : 10 ,
95+ eventStore : { } as any ,
96+ } ) ) . toThrow ( 'Invalid store method set, Invalid store method get, Invalid store method remove, Invalid store method getKeys' ) ;
97+
98+ expect ( ( ) => getBatchEventProcessor ( {
99+ eventDispatcher : getMockEventDispatcher ( ) ,
100+ defaultFlushInterval : 10000 ,
101+ defaultBatchSize : 10 ,
102+ eventStore : { set : 'abc' , get : 'abc' , remove : 'abc' , getKeys : 'abc' } as any ,
103+ } ) ) . toThrow ( 'Invalid store method set, Invalid store method get, Invalid store method remove, Invalid store method getKeys' ) ;
104+
105+ const noop = ( ) => { } ;
106+
107+ expect ( ( ) => getBatchEventProcessor ( {
108+ eventDispatcher : getMockEventDispatcher ( ) ,
109+ defaultFlushInterval : 10000 ,
110+ defaultBatchSize : 10 ,
111+ eventStore : { set : noop , get : 'abc' } as any ,
112+ } ) ) . toThrow ( 'Invalid store method get, Invalid store method remove, Invalid store method getKeys' ) ;
113+
114+ expect ( ( ) => getBatchEventProcessor ( {
115+ eventDispatcher : getMockEventDispatcher ( ) ,
116+ defaultFlushInterval : 10000 ,
117+ defaultBatchSize : 10 ,
118+ eventStore : { set : noop , get : noop , remove : 'abc' } as any ,
119+ } ) ) . toThrow ( 'Invalid store method remove, Invalid store method getKeys' ) ;
120+
121+ expect ( ( ) => getBatchEventProcessor ( {
122+ eventDispatcher : getMockEventDispatcher ( ) ,
123+ defaultFlushInterval : 10000 ,
124+ defaultBatchSize : 10 ,
125+ eventStore : { set : noop , get : noop , remove : noop , getKeys : 'abc' } as any ,
126+ } ) ) . toThrow ( 'Invalid store method getKeys' ) ;
127+ } ) ;
128+
76129 it ( 'returns an instane of BatchEventProcessor if no subclass constructor is provided' , ( ) => {
77130 const options = {
78131 eventDispatcher : getMockEventDispatcher ( ) ,
0 commit comments