|
1 |
| -import { vi } from 'vitest' |
2 | 1 | import type { PayloadAction, WithSlice } from '@reduxjs/toolkit'
|
3 | 2 | import {
|
4 | 3 | asyncThunkCreator,
|
5 | 4 | buildCreateSlice,
|
6 |
| - configureStore, |
7 | 5 | combineSlices,
|
8 |
| - createSlice, |
| 6 | + configureStore, |
9 | 7 | createAction,
|
| 8 | + createSlice, |
10 | 9 | } from '@reduxjs/toolkit'
|
11 | 10 | import {
|
12 |
| - mockConsole, |
13 | 11 | createConsole,
|
14 | 12 | getLog,
|
| 13 | + mockConsole, |
15 | 14 | } from 'console-testing-library/pure'
|
16 | 15 |
|
17 | 16 | type CreateSlice = typeof createSlice
|
@@ -57,7 +56,6 @@ describe('createSlice', () => {
|
57 | 56 |
|
58 | 57 | describe('when initial state is undefined', () => {
|
59 | 58 | beforeEach(() => {
|
60 |
| - |
61 | 59 | vi.stubEnv('NODE_ENV', 'development')
|
62 | 60 |
|
63 | 61 | return vi.unstubAllEnvs
|
@@ -445,25 +443,28 @@ describe('createSlice', () => {
|
445 | 443 | })
|
446 | 444 |
|
447 | 445 | // TODO Determine final production behavior here
|
448 |
| - it.skip('Crashes in production', () => { |
449 |
| - process.env.NODE_ENV = 'production' |
| 446 | + it.todo('Crashes in production', () => { |
| 447 | + vi.stubEnv('NODE_ENV', 'production') |
| 448 | + |
450 | 449 | const { createSlice } = require('../createSlice')
|
451 | 450 |
|
452 |
| - let dummySlice = (createSlice as CreateSlice)({ |
| 451 | + const dummySlice = (createSlice as CreateSlice)({ |
453 | 452 | name: 'dummy',
|
454 | 453 | initialState: [],
|
455 | 454 | reducers: {},
|
456 | 455 | // @ts-ignore
|
457 | 456 | extraReducers: {},
|
458 | 457 | })
|
459 | 458 | const wrapper = () => {
|
460 |
| - let reducer = dummySlice.reducer |
| 459 | + const { reducer } = dummySlice |
461 | 460 | reducer(undefined, { type: 'dummy' })
|
462 | 461 | }
|
463 | 462 |
|
464 | 463 | expect(wrapper).toThrowError(
|
465 | 464 | /The object notation for `createSlice.extraReducers` has been removed/
|
466 | 465 | )
|
| 466 | + |
| 467 | + vi.unstubAllEnvs() |
467 | 468 | })
|
468 | 469 | })
|
469 | 470 | describe('slice selectors', () => {
|
|
0 commit comments