@@ -220,7 +220,7 @@ describe('Unsorted State Adapter', () => {
220
220
} ) ;
221
221
} ) ;
222
222
223
- it ( 'should let you update many entities in the state' , ( ) => {
223
+ it ( 'should let you update many entities by id in the state' , ( ) => {
224
224
const firstChange = { title : 'First Change' } ;
225
225
const secondChange = { title : 'Second Change' } ;
226
226
const withMany = adapter . addAll ( [ TheGreatGatsby , AClockworkOrange ] , state ) ;
@@ -248,6 +248,41 @@ describe('Unsorted State Adapter', () => {
248
248
} ) ;
249
249
} ) ;
250
250
251
+ it ( 'should let you map over entities in the state' , ( ) => {
252
+ const firstChange = { ...TheGreatGatsby , title : 'First change' } ;
253
+ const secondChange = { ...AClockworkOrange , title : 'Second change' } ;
254
+
255
+ const withMany = adapter . addAll (
256
+ [ TheGreatGatsby , AClockworkOrange , AnimalFarm ] ,
257
+ state
258
+ ) ;
259
+
260
+ const withUpdates = adapter . map (
261
+ book =>
262
+ book . title === TheGreatGatsby . title
263
+ ? firstChange
264
+ : book . title === AClockworkOrange . title
265
+ ? secondChange
266
+ : book ,
267
+ withMany
268
+ ) ;
269
+
270
+ expect ( withUpdates ) . toEqual ( {
271
+ ids : [ TheGreatGatsby . id , AClockworkOrange . id , AnimalFarm . id ] ,
272
+ entities : {
273
+ [ TheGreatGatsby . id ] : {
274
+ ...TheGreatGatsby ,
275
+ ...firstChange ,
276
+ } ,
277
+ [ AClockworkOrange . id ] : {
278
+ ...AClockworkOrange ,
279
+ ...secondChange ,
280
+ } ,
281
+ [ AnimalFarm . id ] : AnimalFarm ,
282
+ } ,
283
+ } ) ;
284
+ } ) ;
285
+
251
286
it ( 'should let you add one entity to the state with upsert()' , ( ) => {
252
287
const withOneEntity = adapter . upsertOne ( TheGreatGatsby , state ) ;
253
288
expect ( withOneEntity ) . toEqual ( {
0 commit comments