Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
EskiMojo14 committed Feb 11, 2024
1 parent 244b3e3 commit 52b5604
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/toolkit/src/entities/tests/entity_state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,27 @@ describe('Entity State', () => {
})
})

it('should let you provide initial entities', () => {
const book1: BookModel = { id: 'a', title: 'First' }

const initialState = adapter.getInitialState(undefined, [book1])

expect(initialState).toEqual({
ids: [book1.id],
entities: { [book1.id]: book1 },
})

const additionalProperties = { isHydrated: true }

const initialState2 = adapter.getInitialState(additionalProperties, [book1])

expect(initialState2).toEqual({
...additionalProperties,
ids: [book1.id],
entities: { [book1.id]: book1 },
})
})

it('should allow methods to be passed as reducers', () => {
const upsertBook = createAction<BookModel>('otherBooks/upsert')

Expand Down

0 comments on commit 52b5604

Please sign in to comment.