mirror of
https://github.com/Mastermindzh/react-starter-kit.git
synced 2025-08-23 01:24:51 +02:00
31 lines
889 B
TypeScript
31 lines
889 B
TypeScript
import counterReducer, { increment, decrement, incrementByAmount } from "./counterSlice";
|
|
import { CounterState } from "../models/CounterState";
|
|
|
|
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.only("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);
|
|
});
|
|
});
|