Files
react-starter-kit/src/features/examples/counter/state/counterSlice.spec.ts
Mastermindzh 8496f5cfbe Moved examples into example directory
Moved routes to separate file
Used route constants
2022-07-26 10:32:11 +02:00

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);
});
});