aboutsummaryrefslogtreecommitdiff
path: root/src/features/counter/counterSlice.spec.js
diff options
context:
space:
mode:
authorAdrián Oliva <adrian.oliva@cimat.mx>2023-05-16 19:52:29 -0600
committerAdrián Oliva <adrian.oliva@cimat.mx>2023-05-16 19:52:29 -0600
commit17c1d3d2070ee0c060c3e71a9e5868f004b2b034 (patch)
treec0e7cf17901196b089291c63e8f97058068aed35 /src/features/counter/counterSlice.spec.js
downloadToDo-App-FE-17c1d3d2070ee0c060c3e71a9e5868f004b2b034.tar.gz
ToDo-App-FE-17c1d3d2070ee0c060c3e71a9e5868f004b2b034.zip
Start point.
Visit https://github.com/nvh95/vite-react-template-redux to see original template.
Diffstat (limited to '')
-rw-r--r--src/features/counter/counterSlice.spec.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/features/counter/counterSlice.spec.js b/src/features/counter/counterSlice.spec.js
new file mode 100644
index 0000000..113526b
--- /dev/null
+++ b/src/features/counter/counterSlice.spec.js
@@ -0,0 +1,33 @@
+import counterReducer, {
+ increment,
+ decrement,
+ incrementByAmount,
+} from "./counterSlice";
+
+describe("counter reducer", () => {
+ const initialState = {
+ 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);
+ });
+});