@@ -69,10 +69,27 @@ describe('Sorted State Adapter', () => {
69
69
} ) ;
70
70
} ) ;
71
71
72
- it ( 'should let you add all entities to the state ' , ( ) => {
72
+ it ( 'should remove existing and add new ones on setAll ' , ( ) => {
73
73
const withOneEntity = adapter . addOne ( TheGreatGatsby , state ) ;
74
74
75
- const withAll = adapter . addAll (
75
+ const withAll = adapter . setAll (
76
+ [ AClockworkOrange , AnimalFarm ] ,
77
+ withOneEntity
78
+ ) ;
79
+
80
+ expect ( withAll ) . toEqual ( {
81
+ ids : [ AClockworkOrange . id , AnimalFarm . id ] ,
82
+ entities : {
83
+ [ AClockworkOrange . id ] : AClockworkOrange ,
84
+ [ AnimalFarm . id ] : AnimalFarm ,
85
+ } ,
86
+ } ) ;
87
+ } ) ;
88
+
89
+ it ( 'should remove existing and add new ones on addAll (deprecated)' , ( ) => {
90
+ const withOneEntity = adapter . addOne ( TheGreatGatsby , state ) ;
91
+
92
+ const withAll = adapter . setAll (
76
93
[ AClockworkOrange , AnimalFarm ] ,
77
94
withOneEntity
78
95
) ;
@@ -98,7 +115,7 @@ describe('Sorted State Adapter', () => {
98
115
} ) ;
99
116
100
117
it ( 'should let you remove many entities by id from the state' , ( ) => {
101
- const withAll = adapter . addAll (
118
+ const withAll = adapter . setAll (
102
119
[ TheGreatGatsby , AClockworkOrange , AnimalFarm ] ,
103
120
state
104
121
) ;
@@ -117,7 +134,7 @@ describe('Sorted State Adapter', () => {
117
134
} ) ;
118
135
119
136
it ( 'should let you remove many entities by a predicate from the state' , ( ) => {
120
- const withAll = adapter . addAll (
137
+ const withAll = adapter . setAll (
121
138
[ TheGreatGatsby , AClockworkOrange , AnimalFarm ] ,
122
139
state
123
140
) ;
@@ -133,7 +150,7 @@ describe('Sorted State Adapter', () => {
133
150
} ) ;
134
151
135
152
it ( 'should let you remove all entities from the state' , ( ) => {
136
- const withAll = adapter . addAll (
153
+ const withAll = adapter . setAll (
137
154
[ TheGreatGatsby , AClockworkOrange , AnimalFarm ] ,
138
155
state
139
156
) ;
@@ -182,7 +199,7 @@ describe('Sorted State Adapter', () => {
182
199
} ) ;
183
200
184
201
it ( 'should not change ids state if you attempt to update an entity that does not impact sorting' , ( ) => {
185
- const withAll = adapter . addAll (
202
+ const withAll = adapter . setAll (
186
203
[ TheGreatGatsby , AClockworkOrange , AnimalFarm ] ,
187
204
state
188
205
) ;
@@ -223,7 +240,7 @@ describe('Sorted State Adapter', () => {
223
240
} ) ;
224
241
225
242
it ( 'should resort correctly if same id but sort key update' , ( ) => {
226
- const withAll = adapter . addAll (
243
+ const withAll = adapter . setAll (
227
244
[ TheGreatGatsby , AnimalFarm , AClockworkOrange ] ,
228
245
state
229
246
) ;
@@ -251,7 +268,7 @@ describe('Sorted State Adapter', () => {
251
268
} ) ;
252
269
253
270
it ( 'should resort correctly if the id and sort key update' , ( ) => {
254
- const withOne = adapter . addAll (
271
+ const withOne = adapter . setAll (
255
272
[ TheGreatGatsby , AnimalFarm , AClockworkOrange ] ,
256
273
state
257
274
) ;
@@ -281,7 +298,7 @@ describe('Sorted State Adapter', () => {
281
298
it ( 'should let you update many entities by id in the state' , ( ) => {
282
299
const firstChange = { title : 'Zack' } ;
283
300
const secondChange = { title : 'Aaron' } ;
284
- const withMany = adapter . addAll ( [ TheGreatGatsby , AClockworkOrange ] , state ) ;
301
+ const withMany = adapter . setAll ( [ TheGreatGatsby , AClockworkOrange ] , state ) ;
285
302
286
303
const withUpdates = adapter . updateMany (
287
304
[
@@ -310,7 +327,7 @@ describe('Sorted State Adapter', () => {
310
327
const firstChange = { ...TheGreatGatsby , title : 'First change' } ;
311
328
const secondChange = { ...AClockworkOrange , title : 'Second change' } ;
312
329
313
- const withMany = adapter . addAll (
330
+ const withMany = adapter . setAll (
314
331
[ TheGreatGatsby , AClockworkOrange , AnimalFarm ] ,
315
332
state
316
333
) ;
@@ -372,7 +389,7 @@ describe('Sorted State Adapter', () => {
372
389
373
390
it ( 'should let you upsert many entities in the state' , ( ) => {
374
391
const firstChange = { title : 'Zack' } ;
375
- const withMany = adapter . addAll ( [ TheGreatGatsby ] , state ) ;
392
+ const withMany = adapter . setAll ( [ TheGreatGatsby ] , state ) ;
376
393
377
394
const withUpserts = adapter . upsertMany (
378
395
[ { ...TheGreatGatsby , ...firstChange } , AClockworkOrange ] ,
0 commit comments