Skip to content

Commit 9f29f11

Browse files
author
Shawn Toubeau
committed
adds maze action tests
1 parent 35790b5 commit 9f29f11

File tree

3 files changed

+75
-22
lines changed

3 files changed

+75
-22
lines changed

src/actions/mazeActions/mazeActions.spec.ts

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@ import {
44
handleChangeEnd,
55
makeWall,
66
makeEmpty,
7+
progressBFS,
8+
progressDFS,
9+
progressAstar,
710
CHANGE_START,
811
CHANGE_END,
912
MAKE_WALL,
1013
MAKE_EMPTY,
14+
PROGRESS_BFS,
15+
PROGRESS_DFS,
16+
PROGRESS_ASTAR,
1117
} from "./mazeActions";
1218
import { initialState } from "../../models/maze/initialState";
19+
import { Coord } from "../../models/maze";
1320

1421
describe("Maze Action Tests", () => {
1522
const mockStore = configureStore();
@@ -79,9 +86,74 @@ describe("Maze Action Tests", () => {
7986
});
8087
});
8188

82-
// TODO: progressBFS
89+
describe("Progress BFS", () => {
90+
it("Should call PROGRESS_BFS action", () => {
91+
const queue: Coord[] = [];
92+
const coord = { x: 0, y: 0 };
93+
const neighbors = [
94+
{ x: 1, y: 0 },
95+
{ x: 0, y: 1 },
96+
];
97+
98+
const expectedActions = [
99+
{
100+
type: PROGRESS_BFS,
101+
payload: {
102+
queue: queue,
103+
coord: coord,
104+
neighbors: neighbors,
105+
},
106+
},
107+
];
108+
reduxStore.dispatch(progressBFS(queue, coord, neighbors));
109+
expect(reduxStore.getActions()).toEqual(expectedActions);
110+
});
111+
});
112+
113+
describe("Progress DFS", () => {
114+
it("Should call PROGRESS_DFS action", () => {
115+
const stack: Coord[] = [];
116+
const coord = { x: 0, y: 0 };
117+
const neighbors = [
118+
{ x: 1, y: 0 },
119+
{ x: 0, y: 1 },
120+
];
121+
122+
const expectedActions = [
123+
{
124+
type: PROGRESS_DFS,
125+
payload: {
126+
stack: stack,
127+
coord: coord,
128+
neighbors: neighbors,
129+
},
130+
},
131+
];
132+
reduxStore.dispatch(progressDFS(stack, coord, neighbors));
133+
expect(reduxStore.getActions()).toEqual(expectedActions);
134+
});
135+
});
83136

84-
// TODO: progressDFS
137+
describe("Progress A*", () => {
138+
it("Should call PROGRESS_ASTAR action", () => {
139+
const openSet: Coord[] = [];
140+
const closedSet: Coord[] = [];
141+
const newMazeInfo = initialState.mazeInfo;
142+
const end = { x: 1, y: 1 };
85143

86-
// TODO: progressASTAR
144+
const expectedActions = [
145+
{
146+
type: PROGRESS_ASTAR,
147+
payload: {
148+
openSet: openSet,
149+
closedSet: closedSet,
150+
newMazeInfo: newMazeInfo,
151+
end: end,
152+
},
153+
},
154+
];
155+
reduxStore.dispatch(progressAstar(openSet, closedSet, newMazeInfo, end));
156+
expect(reduxStore.getActions()).toEqual(expectedActions);
157+
});
158+
});
87159
});

src/components/Menu/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ class MenuBar extends React.Component<Props, State> {
282282
/>
283283
<span>Stop</span>
284284
</Button>
285-
{/* TODO: fix */}
286285
{isPlaying && startTime && !endTime ? (
287286
<Menu.Item>
288287
<Moment date={startTime} durationFromNow></Moment>

src/components/Menu/menu.spec.tsx

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ describe("<Menu />", () => {
5252
<Menu {...props} />
5353
</Provider>
5454
);
55-
// console.log('wrapper is', wrapper.debug());
5655
expect(wrapper).toBeDefined();
5756
});
5857

@@ -114,21 +113,4 @@ describe("<Menu />", () => {
114113
wrapper.find(SemanticButton).at(3).simulate("click");
115114
expect(props.onClear).toHaveBeenCalled();
116115
});
117-
118-
// TODO: This fails because it's not hooked up to a reducer
119-
// it("Save Maze button calls action", () => {
120-
// wrapper
121-
// .find(SemanticButton)
122-
// .at(5)
123-
// .simulate("click");
124-
// expect(props.saveMaze).toHaveBeenCalled();
125-
// });
126-
127-
// it("Change dropdown selection", () => {
128-
// wrapper
129-
// .find(SemanticDropdown)
130-
// .simulate("click")
131-
// .simulate("keypress", { key: "Tab" });
132-
// expect(wrapper.find(SemanticDropdown).selectedAlgo).toBeDefined();
133-
// });
134116
});

0 commit comments

Comments
 (0)