UNPKG

@chowdhury/vite-react-redux-ts-starter

Version:

A starter template for React with Typescript using Vite and Redux

37 lines (31 loc) 904 B
import { expect } from "vitest"; import counterReducer, { CounterState, decrement, increment, incrementByAmount, } from "../features/counter/counterSlice"; describe("counter reducer", () => { const initialState: CounterState = { value: 3, status: "idle", }; it("should handle initial state", () => { expect(counterReducer(undefined, { type: "unknown" })).toEqual({ value: 0, status: "idle", }); }); it("should handle increment", () => { const actual = counterReducer(initialState, increment()); expect(actual.value).toEqual(4); }); it("should handle decrement", () => { const actual = counterReducer(initialState, decrement()); expect(actual.value).toEqual(2); }); it("should handle incrementByAmount", () => { const actual = counterReducer(initialState, incrementByAmount(2)); expect(actual.value).toEqual(5); }); });