@@ -5,39 +5,35 @@ import { resource, page } from '~/data/reduxGen';
5
5
6
6
describe ( 'internal' , ( ) => {
7
7
it ( 'generates an action to update one resource' , function ( ) {
8
- const dispatch = jest . fn ( ) ;
9
-
10
8
const config = testConfigOne ;
11
9
12
10
const actions = genActions ( config ) ;
13
- const oneThunk = actions . one ( resource , '23' ) ;
14
- oneThunk ( dispatch ) ;
11
+ const actionOne = actions . one ( resource , '23' ) ;
15
12
16
- expect ( dispatch . mock . calls [ 0 ] [ 0 ] . resource . label ) . toBe ( 'nodebalancer-1' ) ;
17
- expect ( dispatch . mock . calls [ 0 ] [ 0 ] . type ) . toBe ( 'GEN@nodebalancers/ONE' ) ;
18
- expect ( dispatch . mock . calls [ 0 ] [ 0 ] . ids [ 0 ] ) . toBe ( 23 ) ;
13
+ expect ( actionOne . resource . label ) . toBe ( 'nodebalancer-1' ) ;
14
+ expect ( actionOne . type ) . toBe ( 'GEN@nodebalancers/ONE' ) ;
15
+ expect ( actionOne . ids [ 0 ] ) . toBe ( 23 ) ;
19
16
} ) ;
20
17
21
18
it ( 'generates an action to update many resources' , function ( ) {
22
- const dispatch = jest . fn ( ) ;
23
-
24
19
const config = testConfigMany ;
25
20
26
21
const actions = genActions ( config ) ;
27
- const manyThunk = actions . many ( page ) ;
28
- manyThunk ( dispatch ) ;
29
- expect ( dispatch . mock . calls [ 0 ] [ 0 ] . page . nodebalancers [ 0 ] . label )
22
+ const actionMany = actions . many ( page ) ;
23
+
24
+ expect ( actionMany . page . nodebalancers [ 0 ] . label )
30
25
. toBe ( 'nodebalancer-1' ) ;
31
- expect ( dispatch . mock . calls [ 0 ] [ 0 ] . page . nodebalancers [ 1 ] . label )
26
+ expect ( actionMany . page . nodebalancers [ 1 ] . label )
32
27
. toBe ( 'nodebalancer-2' ) ;
33
- expect ( dispatch . mock . calls [ 0 ] [ 0 ] . type ) . toBe ( 'GEN@nodebalancers/MANY' ) ;
28
+ expect ( actionMany . type ) . toBe ( 'GEN@nodebalancers/MANY' ) ;
34
29
} ) ;
35
30
36
31
it ( 'generates an action to delete a resource' , function ( ) {
37
32
const config = testConfigDelete ;
38
33
39
34
const actions = genActions ( config ) ;
40
35
const deleteAction = actions . delete ( '23' ) ;
36
+
41
37
expect ( deleteAction . ids [ 0 ] ) . toBe ( 23 ) ;
42
38
expect ( deleteAction . type ) . toBe ( 'GEN@nodebalancers/DELETE' ) ;
43
39
} ) ;
0 commit comments