This commit is contained in:
QkoSad
2023-08-08 16:02:54 +03:00
commit 0a7a469d56
315 changed files with 426907 additions and 0 deletions
+81
View File
@@ -0,0 +1,81 @@
import deepFreeze from "deep-freeze";
import counterReducer from "./reducer";
describe("unicafe reducer", () => {
const initialState = {
good: 0,
ok: 0,
bad: 0,
};
test("should return a proper initial state when called with undefined state", () => {
const state = {};
const action = {
type: "DO_NOTHING",
};
deepFreeze(state);
const newState = counterReducer(undefined, action);
expect(newState).toEqual(initialState);
});
test("good is incremented", () => {
const action = {
type: "GOOD",
};
const state = initialState;
deepFreeze(state);
const newState = counterReducer(state, action);
expect(newState).toEqual({
good: 1,
ok: 0,
bad: 0,
});
});
test("ok is incremented", () => {
const action = {
type: "OK",
};
const state = initialState;
deepFreeze(state);
const newState = counterReducer(state, action);
expect(newState).toEqual({
good: 0,
ok: 1,
bad: 0,
});
});
test("bad is incremented", () => {
const action = {
type: "BAD",
};
const state = initialState;
deepFreeze(state);
const newState = counterReducer(state, action);
expect(newState).toEqual({
good: 0,
ok: 0,
bad: 1,
});
});
test("state is reset", () => {
const action = {
type: "ZERO",
};
const state = initialState;
deepFreeze(state);
const newState = counterReducer(state, action);
expect(newState).toEqual({
good: 0,
ok: 0,
bad: 0,
});
});
});