Skip to content

Commit

Permalink
Improve stable sorting test checks
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Apr 29, 2024
1 parent d60cf84 commit 455bf7a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/toolkit/src/entities/tests/sorted_state_adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,22 +360,30 @@ describe('Sorted State Adapter', () => {
const withInitialItems = sortedItemsAdapter.setAll(
sortedItemsAdapter.getInitialState(),
[
{ id: 'C', order: 3, ts: 0 },
{ id: 'A', order: 1, ts: 0 },
{ id: 'F', order: 4, ts: 0 },
{ id: 'B', order: 2, ts: 0 },
{ id: 'C', order: 3, ts: 0 },
{ id: 'D', order: 3, ts: 0 },
{ id: 'E', order: 3, ts: 0 },
],
)

expect(withInitialItems.ids).toEqual(['A', 'B', 'C', 'D', 'E'])
expect(withInitialItems.ids).toEqual(['A', 'B', 'C', 'D', 'E', 'F'])

const updated = sortedItemsAdapter.updateOne(withInitialItems, {
id: 'C',
changes: { ts: 5 },
})

expect(updated.ids).toEqual(['A', 'B', 'C', 'D', 'E'])
expect(updated.ids).toEqual(['A', 'B', 'C', 'D', 'E', 'F'])

const updated2 = sortedItemsAdapter.updateOne(withInitialItems, {
id: 'D',
changes: { ts: 6 },
})

expect(updated2.ids).toEqual(['A', 'B', 'C', 'D', 'E', 'F'])
})

it('should let you update many entities by id in the state', () => {
Expand Down

0 comments on commit 455bf7a

Please sign in to comment.