@@ -34,7 +34,7 @@ describe('assertions', () => {
3434
3535 it ( 'should be function' , ( ) => { expect ( unrollActions ) . toBeA ( 'function' ) ; } ) ;
3636
37- it ( 'should return flat array with all actions' , ( ) => {
37+ it ( 'should return flat array with all the actions' , ( ) => {
3838 unrollActions ( { } , asyncActionCreator ( ) ) . then ( ( result ) => {
3939 const expectedActions = [
4040 { type : '0-0' } ,
@@ -50,20 +50,62 @@ describe('assertions', () => {
5050 } ) ;
5151
5252 describe ( 'assertDispatchedActions' , ( ) => {
53- it ( 'should be function' , ( ) => { expect ( assertDispatchedActions ) . toBeA ( 'function' ) ; } ) ;
53+ it ( 'should be function' , ( ) => {
54+ expect ( assertDispatchedActions ) . toBeA ( 'function' ) ;
55+ } ) ;
56+
57+ describe ( 'when expected action was not dispatched' , ( ) => {
58+ it ( 'should throw an error' , ( ) => {
59+ const dispatchedActions = [
60+ { type : '0-0' } ,
61+ { type : '0-1' }
62+ ] ;
63+ const expectedActions = [
64+ { type : '0-0' } ,
65+ { type : '10-0' }
66+ ] ;
67+
68+ expect ( ( ) => { assertDispatchedActions ( dispatchedActions , expectedActions ) ; } )
69+ . toThrow ( ) ;
70+ } ) ;
71+ } ) ;
5472
55- it ( 'should throw error if expected action was not dispatched ' , ( ) => {
73+ it ( 'should accept expected duplicate actions ' , ( ) => {
5674 const dispatchedActions = [
5775 { type : '0-0' } ,
58- { type : '0-1' }
76+ { type : '0-1' } ,
77+ { type : '0-0' } ,
78+ { type : '0-2' }
5979 ] ;
6080 const expectedActions = [
6181 { type : '0-0' } ,
62- { type : '10-0' }
82+ { type : '0-0' } ,
83+ { type : '0-1' } ,
84+ { type : '0-2' }
6385 ] ;
6486
6587 expect ( ( ) => { assertDispatchedActions ( dispatchedActions , expectedActions ) ; } )
66- . toThrow ( ) ;
88+ . toNotThrow ( ) ;
89+ } ) ;
90+
91+ describe ( 'when expected duplicate actions were not dispatched' , ( ) => {
92+ it ( 'should throw an error' , ( ) => {
93+ const dispatchedActions = [
94+ { type : '0-0' } ,
95+ { type : '0-1' } ,
96+ { type : '0-2' } ,
97+ { type : '0-3' }
98+ ] ;
99+ const expectedActions = [
100+ { type : '0-0' } ,
101+ { type : '0-0' } ,
102+ { type : '0-1' } ,
103+ { type : '0-2' }
104+ ] ;
105+
106+ expect ( ( ) => { assertDispatchedActions ( dispatchedActions , expectedActions ) ; } )
107+ . toThrow ( ) ;
108+ } ) ;
67109 } ) ;
68110 } ) ;
69111 } ) ;
0 commit comments