Skip to content

Commit 52b5604

Browse files
committed
add test
1 parent 244b3e3 commit 52b5604

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,27 @@ describe('Entity State', () => {
3535
})
3636
})
3737

38+
it('should let you provide initial entities', () => {
39+
const book1: BookModel = { id: 'a', title: 'First' }
40+
41+
const initialState = adapter.getInitialState(undefined, [book1])
42+
43+
expect(initialState).toEqual({
44+
ids: [book1.id],
45+
entities: { [book1.id]: book1 },
46+
})
47+
48+
const additionalProperties = { isHydrated: true }
49+
50+
const initialState2 = adapter.getInitialState(additionalProperties, [book1])
51+
52+
expect(initialState2).toEqual({
53+
...additionalProperties,
54+
ids: [book1.id],
55+
entities: { [book1.id]: book1 },
56+
})
57+
})
58+
3859
it('should allow methods to be passed as reducers', () => {
3960
const upsertBook = createAction<BookModel>('otherBooks/upsert')
4061

0 commit comments

Comments
 (0)