Skip to content

Commit 455bf7a

Browse files
committed
Improve stable sorting test checks
1 parent d60cf84 commit 455bf7a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

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

+11-3
Original file line numberDiff line numberDiff line change
@@ -360,22 +360,30 @@ describe('Sorted State Adapter', () => {
360360
const withInitialItems = sortedItemsAdapter.setAll(
361361
sortedItemsAdapter.getInitialState(),
362362
[
363+
{ id: 'C', order: 3, ts: 0 },
363364
{ id: 'A', order: 1, ts: 0 },
365+
{ id: 'F', order: 4, ts: 0 },
364366
{ id: 'B', order: 2, ts: 0 },
365-
{ id: 'C', order: 3, ts: 0 },
366367
{ id: 'D', order: 3, ts: 0 },
367368
{ id: 'E', order: 3, ts: 0 },
368369
],
369370
)
370371

371-
expect(withInitialItems.ids).toEqual(['A', 'B', 'C', 'D', 'E'])
372+
expect(withInitialItems.ids).toEqual(['A', 'B', 'C', 'D', 'E', 'F'])
372373

373374
const updated = sortedItemsAdapter.updateOne(withInitialItems, {
374375
id: 'C',
375376
changes: { ts: 5 },
376377
})
377378

378-
expect(updated.ids).toEqual(['A', 'B', 'C', 'D', 'E'])
379+
expect(updated.ids).toEqual(['A', 'B', 'C', 'D', 'E', 'F'])
380+
381+
const updated2 = sortedItemsAdapter.updateOne(withInitialItems, {
382+
id: 'D',
383+
changes: { ts: 6 },
384+
})
385+
386+
expect(updated2.ids).toEqual(['A', 'B', 'C', 'D', 'E', 'F'])
379387
})
380388

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

0 commit comments

Comments
 (0)