Skip to content

Commit 75aced4

Browse files
committed
Add test to verify multiple updates get applied to one item by ID
1 parent 93cd136 commit 75aced4

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

packages/toolkit/src/entities/tests/sorted_state_adapter.test.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -680,12 +680,20 @@ describe('Sorted State Adapter', () => {
680680
test('updateMany', () => {
681681
const firstChange = { title: 'First Change' }
682682
const secondChange = { title: 'Second Change' }
683-
const withMany = adapter.setAll(state, [TheGreatGatsby, AClockworkOrange])
683+
const thirdChange = { title: 'Third Change' }
684+
const fourthChange = { author: 'Fourth Change' }
685+
const withMany = adapter.setAll(state, [
686+
TheGreatGatsby,
687+
AClockworkOrange,
688+
TheHobbit,
689+
])
684690

685691
const result = createNextState(withMany, (draft) => {
686692
adapter.updateMany(draft, [
687-
{ id: TheGreatGatsby.id, changes: firstChange },
688-
{ id: AClockworkOrange.id, changes: secondChange },
693+
{ id: TheHobbit.id, changes: firstChange },
694+
{ id: TheGreatGatsby.id, changes: secondChange },
695+
{ id: AClockworkOrange.id, changes: thirdChange },
696+
{ id: TheHobbit.id, changes: fourthChange },
689697
])
690698
})
691699

@@ -694,14 +702,20 @@ describe('Sorted State Adapter', () => {
694702
"entities": Object {
695703
"aco": Object {
696704
"id": "aco",
697-
"title": "Second Change",
705+
"title": "Third Change",
698706
},
699707
"tgg": Object {
700708
"id": "tgg",
709+
"title": "Second Change",
710+
},
711+
"th": Object {
712+
"author": "Fourth Change",
713+
"id": "th",
701714
"title": "First Change",
702715
},
703716
},
704717
"ids": Array [
718+
"th",
705719
"tgg",
706720
"aco",
707721
],

0 commit comments

Comments
 (0)