Skip to content

Commit 05b878d

Browse files
committed
test: should return an error when initial state is undefined
1 parent 070c7c0 commit 05b878d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/toolkit/src/tests/createSlice.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ describe('createSlice', () => {
3434
})
3535
})
3636

37+
describe('when initial state is undefined', () => {
38+
it('should throw an error', () => {
39+
expect(() =>
40+
createSlice({
41+
name: 'test',
42+
reducers: {},
43+
initialState: undefined,
44+
})
45+
).toThrowErrorMatchingInlineSnapshot(`"initial state must be different of undefined"`)
46+
})
47+
})
48+
3749
describe('when passing slice', () => {
3850
const { actions, reducer, caseReducers } = createSlice({
3951
reducers: {

0 commit comments

Comments
 (0)