Skip to content

Commit b5b8858

Browse files
author
Shawn Toubeau
committed
adds menu action tests
1 parent 0257c79 commit b5b8858

File tree

1 file changed

+60
-12
lines changed

1 file changed

+60
-12
lines changed

src/actions/menuActions/menuActions.spec.ts

+60-12
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ import {
1616
handleChangeAlgo,
1717
loadMaze,
1818
LOAD_MAZE,
19+
CHANGE_SPEED,
20+
handleChangeSpeed,
21+
UPDATE_GRID_SIZE,
22+
handleChangeGridSize,
23+
RANDOMIZE_WALLS,
24+
randomizeWalls,
1925
} from "./menuActions";
2026
import { ButtonProps, DropdownProps } from "semantic-ui-react";
2127
import { initialState } from "../../models/menu/initialState";
@@ -30,7 +36,7 @@ describe("Navbar Action Tests", () => {
3036
});
3137

3238
describe("Start Visualization Test", () => {
33-
it("Should dispatch correct action", () => {
39+
it("Should call START_VISUALIZATION action", () => {
3440
const expectedActions = [
3541
{
3642
type: START_VISUALIZATION,
@@ -48,7 +54,7 @@ describe("Navbar Action Tests", () => {
4854
});
4955

5056
describe("Pause Visualization Test", () => {
51-
it("Should modify redux store", () => {
57+
it("Should call PAUSE_VISUALIZATION action", () => {
5258
const expectedActions = [
5359
{
5460
type: PAUSE_VISUALIZATION,
@@ -66,7 +72,7 @@ describe("Navbar Action Tests", () => {
6672
});
6773

6874
describe("Stop Visualization Test", () => {
69-
it("Should dispatch correct action", () => {
75+
it("Should call STOP_VISUALIZATION action", () => {
7076
const expectedActions = [
7177
{
7278
type: STOP_VISUALIZATION,
@@ -84,10 +90,26 @@ describe("Navbar Action Tests", () => {
8490
});
8591
});
8692

87-
// TODO: change speed
93+
describe("Change Visualization Speed", () => {
94+
it("Should call CHANGE_SPEED action", () => {
95+
const expectedActions = [
96+
{
97+
type: CHANGE_SPEED,
98+
payload: undefined,
99+
},
100+
];
101+
reduxStore.dispatch(
102+
handleChangeSpeed(
103+
{ target: {} } as React.MouseEvent<HTMLButtonElement, MouseEvent>,
104+
{} as DropdownProps
105+
)
106+
);
107+
expect(reduxStore.getActions()).toEqual(expectedActions);
108+
});
109+
});
88110

89111
describe("Change Algorithm Test", () => {
90-
it("Should dispatch correct action", () => {
112+
it("Should call CHANGE_ALGO action", () => {
91113
const expectedActions = [
92114
{
93115
type: CHANGE_ALGO,
@@ -104,10 +126,27 @@ describe("Navbar Action Tests", () => {
104126
});
105127
});
106128

107-
// TODO: change grid size
129+
describe("Change Grid Size Test", () => {
130+
it("Should call UPDATE_GRID_SIZE action", () => {
131+
const cols = 20;
132+
const rows = 20;
133+
134+
const expectedActions = [
135+
{
136+
type: UPDATE_GRID_SIZE,
137+
payload: {
138+
cols: cols,
139+
rows: rows,
140+
},
141+
},
142+
];
143+
reduxStore.dispatch(handleChangeGridSize(cols, rows));
144+
expect(reduxStore.getActions()).toEqual(expectedActions);
145+
});
146+
});
108147

109148
describe("Move Start Point Test", () => {
110-
it("Should modify redux store", () => {
149+
it("Should call TOGGLE_MOVE_START action", () => {
111150
const expectedActions = [
112151
{
113152
type: TOGGLE_MOVE_START,
@@ -125,7 +164,7 @@ describe("Navbar Action Tests", () => {
125164
});
126165

127166
describe("Move End Point Test", () => {
128-
it("Should modify redux store", () => {
167+
it("Should call TOGGLE_MOVE_END action", () => {
129168
const expectedActions = [
130169
{
131170
type: TOGGLE_MOVE_END,
@@ -142,10 +181,21 @@ describe("Navbar Action Tests", () => {
142181
});
143182
});
144183

145-
// TODO: randomize walls
184+
describe("Randomize Walls Test", () => {
185+
it("Should call RANDOMIZE_WALLS action", () => {
186+
const expectedActions = [
187+
{
188+
type: RANDOMIZE_WALLS,
189+
payload: null,
190+
},
191+
];
192+
reduxStore.dispatch(randomizeWalls());
193+
expect(reduxStore.getActions()).toEqual(expectedActions);
194+
});
195+
});
146196

147197
describe("Clear Grid Test", () => {
148-
it("Should dispatch correct action", () => {
198+
it("Should call CLEAR_GRID action", () => {
149199
const expectedActions = [
150200
{
151201
type: CLEAR_GRID,
@@ -162,8 +212,6 @@ describe("Navbar Action Tests", () => {
162212
});
163213
});
164214

165-
// TODO: save maze
166-
167215
describe("Load Maze Test", () => {
168216
it("Should call LOAD_MAZE action", () => {
169217
const maze = generateMaze(5, 5, false);

0 commit comments

Comments
 (0)