7
7
import * as actions from './<%= dasherize(name) %>.actions' ;
8
8
import {
9
9
< %= name % > Reducer ,
10
- initialState ,
10
+ initial < %= classify ( name ) % > State ,
11
11
getSelectedId ,
12
12
getLoading ,
13
13
getError ,
@@ -16,7 +16,7 @@ import {
16
16
import { Update } from '@ngrx/entity' ;
17
17
18
18
const INITIAL_STATE_WITH_ERROR = {
19
- ...initialState ,
19
+ ...initial < %= classify ( name ) % > State ,
20
20
error : 'some error'
21
21
} ;
22
22
const BLANK_ERROR_MESSAGE = '' ;
@@ -26,7 +26,7 @@ describe('<%= name %>Reducer', () => {
26
26
it ( 'should return the default state upon an undefined action' , ( ) => {
27
27
const action = { type : 'NOT DEFINED' } as any ;
28
28
29
- expect ( < %= name % > Reducer ( initialState , action ) ) . toEqual ( initialState ) ;
29
+ expect ( < %= name % > Reducer ( initial < %= classify ( name ) % > State , action ) ) . toEqual ( initial < %= classify ( name ) % > State ) ;
30
30
} ) ;
31
31
} ) ;
32
32
@@ -35,7 +35,7 @@ describe('<%= name %>Reducer', () => {
35
35
const action = new actions . Create < %= classify ( name ) % > ( { < %= name % > : generate < %= classify ( name ) % > ( ) } ) ;
36
36
37
37
expect ( < %= name % > Reducer ( INITIAL_STATE_WITH_ERROR , action ) ) . toEqual ( {
38
- ...initialState ,
38
+ ...initial < %= classify ( name ) % > State ,
39
39
loading : true ,
40
40
error : BLANK_ERROR_MESSAGE
41
41
} ) ;
@@ -48,7 +48,7 @@ describe('<%= name %>Reducer', () => {
48
48
const action = new actions . Create < %= classify ( name ) % > Success ( { result } ) ;
49
49
50
50
expect ( < %= name % > Reducer ( INITIAL_STATE_WITH_ERROR , action ) ) . toEqual ( {
51
- ...initialState ,
51
+ ...initial < %= classify ( name ) % > State ,
52
52
...generate < %= classify ( name ) % > Map ( [ result ] ) ,
53
53
loading : false ,
54
54
error : BLANK_ERROR_MESSAGE
@@ -61,8 +61,8 @@ describe('<%= name %>Reducer', () => {
61
61
const error = 'test insert error' ;
62
62
const action = new actions . Create < %= classify ( name ) % > Fail ( { error } ) ;
63
63
64
- expect ( < %= name % > Reducer ( initialState , action ) ) . toEqual ( {
65
- ...initialState ,
64
+ expect ( < %= name % > Reducer ( initial < %= classify ( name ) % > State , action ) ) . toEqual ( {
65
+ ...initial < %= classify ( name ) % > State ,
66
66
loading : false ,
67
67
error : `<%= classify(name) %> insert failed: ${ error } `
68
68
} ) ;
@@ -71,14 +71,14 @@ describe('<%= name %>Reducer', () => {
71
71
72
72
describe ( 'upon SearchAll<%= classify(name) %>Entities' , ( ) => {
73
73
it ( 'should remove <%= classify(name) %> entities, set loading to true, and clear any error' , ( ) => {
74
- const initialStateWith < %= classify ( name ) % > Entities = {
74
+ const initial < %= classify ( name ) % > StateWith < %= classify ( name ) % > Entities = {
75
75
...INITIAL_STATE_WITH_ERROR ,
76
76
...generate < %= classify ( name ) % > Map ( )
77
77
} ;
78
78
const action = new actions . SearchAll < %= classify ( name ) % > Entities ( ) ;
79
79
80
- expect ( < %= name % > Reducer ( initialStateWith < %= classify ( name ) % > Entities , action ) ) . toEqual ( {
81
- ...initialState ,
80
+ expect ( < %= name % > Reducer ( initial < %= classify ( name ) % > StateWith < %= classify ( name ) % > Entities , action ) ) . toEqual ( {
81
+ ...initial < %= classify ( name ) % > State ,
82
82
loading : true ,
83
83
error : BLANK_ERROR_MESSAGE
84
84
} ) ;
@@ -91,7 +91,7 @@ describe('<%= name %>Reducer', () => {
91
91
const action = new actions . SearchAll < %= classify ( name ) % > EntitiesSuccess ( { result } ) ;
92
92
93
93
expect ( < %= name % > Reducer ( INITIAL_STATE_WITH_ERROR , action ) ) . toEqual ( {
94
- ...initialState ,
94
+ ...initial < %= classify ( name ) % > State ,
95
95
...generate < %= classify ( name ) % > Map ( result ) ,
96
96
loading : false ,
97
97
error : BLANK_ERROR_MESSAGE
@@ -104,8 +104,8 @@ describe('<%= name %>Reducer', () => {
104
104
const error = 'test search error' ;
105
105
const action = new actions . SearchAll < %= classify ( name ) % > EntitiesFail ( { error } ) ;
106
106
107
- expect ( < %= name % > Reducer ( initialState , action ) ) . toEqual ( {
108
- ...initialState ,
107
+ expect ( < %= name % > Reducer ( initial < %= classify ( name ) % > State , action ) ) . toEqual ( {
108
+ ...initial < %= classify ( name ) % > State ,
109
109
loading : false ,
110
110
error : `<%= classify(name) %> search failed: ${ error } `
111
111
} ) ;
@@ -115,14 +115,14 @@ describe('<%= name %>Reducer', () => {
115
115
describe ( 'upon Load<%= classify(name) %>ById' , ( ) => {
116
116
it ( 'should remove <%= name %> entities, set selected id, and clear any error' , ( ) => {
117
117
const id = 8675309 ;
118
- const initialStateWith < %= classify ( name ) % > Entities = {
118
+ const initial < %= classify ( name ) % > StateWith < %= classify ( name ) % > Entities = {
119
119
...INITIAL_STATE_WITH_ERROR ,
120
120
...generate < %= classify ( name ) % > Map ( )
121
121
} ;
122
122
const action = new actions . Load < %= classify ( name ) % > ById ( { id } ) ;
123
123
124
- expect ( < %= name % > Reducer ( initialStateWith < %= classify ( name ) % > Entities , action ) ) . toEqual ( {
125
- ...initialState ,
124
+ expect ( < %= name % > Reducer ( initial < %= classify ( name ) % > StateWith < %= classify ( name ) % > Entities , action ) ) . toEqual ( {
125
+ ...initial < %= classify ( name ) % > State ,
126
126
selectedId : id ,
127
127
loading : true ,
128
128
error : BLANK_ERROR_MESSAGE
@@ -136,7 +136,7 @@ describe('<%= name %>Reducer', () => {
136
136
const action = new actions . Load < %= classify ( name ) % > ByIdSuccess ( { result } ) ;
137
137
138
138
expect ( < %= name % > Reducer ( INITIAL_STATE_WITH_ERROR , action ) ) . toEqual ( {
139
- ...initialState ,
139
+ ...initial < %= classify ( name ) % > State ,
140
140
...generate < %= classify ( name ) % > Map ( [ result ] ) ,
141
141
loading : false ,
142
142
error : BLANK_ERROR_MESSAGE
@@ -149,8 +149,8 @@ describe('<%= name %>Reducer', () => {
149
149
const error = 'test load by id error' ;
150
150
const action = new actions . Load < %= classify ( name ) % > ByIdFail ( { error } ) ;
151
151
152
- expect ( < %= name % > Reducer ( initialState , action ) ) . toEqual ( {
153
- ...initialState ,
152
+ expect ( < %= name % > Reducer ( initial < %= classify ( name ) % > State , action ) ) . toEqual ( {
153
+ ...initial < %= classify ( name ) % > State ,
154
154
loading : false ,
155
155
error : `<%= classify(name) %> load failed: ${ error } `
156
156
} ) ;
@@ -163,7 +163,7 @@ describe('<%= name %>Reducer', () => {
163
163
const action = new actions . Update < %= classify ( name ) % > ( { < %= name % > } ) ;
164
164
165
165
expect ( < %= name % > Reducer ( INITIAL_STATE_WITH_ERROR , action ) ) . toEqual ( {
166
- ...initialState ,
166
+ ...initial < %= classify ( name ) % > State ,
167
167
loading : true ,
168
168
error : BLANK_ERROR_MESSAGE
169
169
} ) ;
@@ -173,7 +173,7 @@ describe('<%= name %>Reducer', () => {
173
173
describe ( 'upon Update<%= classify(name) %>Success' , ( ) => {
174
174
it ( 'should add the given <%= classify(name) %>, set loading to false, and clear any error' , ( ) => {
175
175
const < %= name % > = generate < %= classify ( name ) % > ( ) ;
176
- const initialStateWith < %= classify ( name ) % > = {
176
+ const initial < %= classify ( name ) % > StateWith < %= classify ( name ) % > = {
177
177
...INITIAL_STATE_WITH_ERROR ,
178
178
...generate < %= classify ( name ) % > Map ( [ < %= name % > ] )
179
179
} ;
@@ -188,8 +188,8 @@ describe('<%= name %>Reducer', () => {
188
188
} as Update << %= classify ( name ) % >> ;
189
189
const action = new actions . Update < %= classify ( name ) % > Success ( { update } ) ;
190
190
191
- expect ( < %= name % > Reducer ( initialStateWith < %= classify ( name ) % > , action ) ) . toEqual ( {
192
- ...initialStateWith < %= classify ( name ) % > ,
191
+ expect ( < %= name % > Reducer ( initial < %= classify ( name ) % > StateWith < %= classify ( name ) % > , action ) ) . toEqual ( {
192
+ ...initial < %= classify ( name ) % > StateWith < %= classify ( name ) % > ,
193
193
...generate < %= classify ( name ) % > Map ( [ updated < %= classify ( name ) % > ] ) ,
194
194
loading : false ,
195
195
error : BLANK_ERROR_MESSAGE
@@ -202,8 +202,8 @@ describe('<%= name %>Reducer', () => {
202
202
const error = 'test update error' ;
203
203
const action = new actions . Update < %= classify ( name ) % > Fail ( { error } ) ;
204
204
205
- expect ( < %= name % > Reducer ( initialState , action ) ) . toEqual ( {
206
- ...initialState ,
205
+ expect ( < %= name % > Reducer ( initial < %= classify ( name ) % > State , action ) ) . toEqual ( {
206
+ ...initial < %= classify ( name ) % > State ,
207
207
loading : false ,
208
208
error : `<%= classify(name) %> update failed: ${ error } `
209
209
} ) ;
@@ -216,7 +216,7 @@ describe('<%= name %>Reducer', () => {
216
216
const action = new actions . Delete < %= classify ( name ) % > ById ( { id } ) ;
217
217
218
218
expect ( < %= name % > Reducer ( INITIAL_STATE_WITH_ERROR , action ) ) . toEqual ( {
219
- ...initialState ,
219
+ ...initial < %= classify ( name ) % > State ,
220
220
selectedId : id ,
221
221
loading : true ,
222
222
error : BLANK_ERROR_MESSAGE
@@ -233,16 +233,16 @@ describe('<%= name %>Reducer', () => {
233
233
...expected < %= classify ( name ) % > Entities ,
234
234
< %= name % > ToBeRemoved
235
235
] ;
236
- const initialStateWithAll < %= classify ( name ) % > Entities = {
236
+ const initial < %= classify ( name ) % > StateWithAll < %= classify ( name ) % > Entities = {
237
237
...INITIAL_STATE_WITH_ERROR ,
238
238
...generate < %= classify ( name ) % > Map ( < %= name % > EntitiesWith < %= classify ( name ) % > ToBeRemoved )
239
239
} ;
240
240
const action = new actions . Delete < %= classify ( name ) % > ByIdSuccess ( { id } ) ;
241
241
242
242
expect (
243
- < %= name % > Reducer ( initialStateWithAll < %= classify ( name ) % > Entities , action )
243
+ < %= name % > Reducer ( initial < %= classify ( name ) % > StateWithAll < %= classify ( name ) % > Entities , action )
244
244
) . toEqual ( {
245
- ...initialStateWithAll < %= classify ( name ) % > Entities ,
245
+ ...initial < %= classify ( name ) % > StateWithAll < %= classify ( name ) % > Entities ,
246
246
...generate < %= classify ( name ) % > Map ( expected < %= classify ( name ) % > Entities ) ,
247
247
loading : false ,
248
248
error : BLANK_ERROR_MESSAGE
@@ -255,8 +255,8 @@ describe('<%= name %>Reducer', () => {
255
255
const error = 'test delete error' ;
256
256
const action = new actions . Delete < %= classify ( name ) % > ByIdFail ( { error } ) ;
257
257
258
- expect ( < %= name % > Reducer ( initialState , action ) ) . toEqual ( {
259
- ...initialState ,
258
+ expect ( < %= name % > Reducer ( initial < %= classify ( name ) % > State , action ) ) . toEqual ( {
259
+ ...initial < %= classify ( name ) % > State ,
260
260
loading : false ,
261
261
error : `<%= classify(name) %> delete failed: ${ error } `
262
262
} ) ;
@@ -273,8 +273,8 @@ describe('<%= name %>Reducer', () => {
273
273
} ;
274
274
const action = new actions . SetSearchQuery ( query ) ;
275
275
276
- expect ( < %= name % > Reducer ( initialState , action ) ) . toEqual ( {
277
- ...initialState ,
276
+ expect ( < %= name % > Reducer ( initial < %= classify ( name ) % > State , action ) ) . toEqual ( {
277
+ ...initial < %= classify ( name ) % > State ,
278
278
query
279
279
} ) ;
280
280
} ) ;
@@ -286,7 +286,7 @@ describe('<%= name %>Reducer', () => {
286
286
const action = new actions . Select < %= classify ( name ) % > ById ( { id } ) ;
287
287
288
288
expect ( < %= name % > Reducer ( INITIAL_STATE_WITH_ERROR , action ) ) . toEqual ( {
289
- ...initialState ,
289
+ ...initial < %= classify ( name ) % > State ,
290
290
selectedId : id ,
291
291
error : BLANK_ERROR_MESSAGE
292
292
} ) ;
@@ -297,12 +297,12 @@ describe('<%= name %>Reducer', () => {
297
297
describe ( 'getters' , ( ) => {
298
298
describe ( 'getSelectedId' , ( ) => {
299
299
it ( 'should return the selected id' , ( ) => {
300
- expect ( getSelectedId ( initialState ) ) . toEqual ( initialState . selectedId ) ;
300
+ expect ( getSelectedId ( initial < %= classify ( name ) % > State ) ) . toEqual ( initial < %= classify ( name ) % > State . selectedId ) ;
301
301
} ) ;
302
302
} ) ;
303
303
describe ( 'getLoading' , ( ) => {
304
304
it ( 'should return the selected id' , ( ) => {
305
- expect ( getLoading ( initialState ) ) . toEqual ( initialState . loading ) ;
305
+ expect ( getLoading ( initial < %= classify ( name ) % > State ) ) . toEqual ( initial < %= classify ( name ) % > State . loading ) ;
306
306
} ) ;
307
307
} ) ;
308
308
describe ( 'getError' , ( ) => {
@@ -313,8 +313,8 @@ describe('getters', () => {
313
313
} ) ;
314
314
describe ( 'getQuery' , ( ) => {
315
315
it ( 'should return the selected id' , ( ) => {
316
- expect ( getQuery ( initialState ) )
317
- . toEqual ( initialState . query ) ;
316
+ expect ( getQuery ( initial < %= classify ( name ) % > State ) )
317
+ . toEqual ( initial < %= classify ( name ) % > State . query ) ;
318
318
} ) ;
319
319
} ) ;
320
320
} ) ;
0 commit comments