@@ -34,7 +34,7 @@ describe('assertions', () => {
34
34
35
35
it ( 'should be function' , ( ) => { expect ( unrollActions ) . toBeA ( 'function' ) ; } ) ;
36
36
37
- it ( 'should return flat array with all actions' , ( ) => {
37
+ it ( 'should return flat array with all the actions' , ( ) => {
38
38
unrollActions ( { } , asyncActionCreator ( ) ) . then ( ( result ) => {
39
39
const expectedActions = [
40
40
{ type : '0-0' } ,
@@ -50,20 +50,62 @@ describe('assertions', () => {
50
50
} ) ;
51
51
52
52
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
+ } ) ;
54
72
55
- it ( 'should throw error if expected action was not dispatched ' , ( ) => {
73
+ it ( 'should accept expected duplicate actions ' , ( ) => {
56
74
const dispatchedActions = [
57
75
{ type : '0-0' } ,
58
- { type : '0-1' }
76
+ { type : '0-1' } ,
77
+ { type : '0-0' } ,
78
+ { type : '0-2' }
59
79
] ;
60
80
const expectedActions = [
61
81
{ type : '0-0' } ,
62
- { type : '10-0' }
82
+ { type : '0-0' } ,
83
+ { type : '0-1' } ,
84
+ { type : '0-2' }
63
85
] ;
64
86
65
87
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
+ } ) ;
67
109
} ) ;
68
110
} ) ;
69
111
} ) ;
0 commit comments