@@ -16,6 +16,12 @@ import {
16
16
handleChangeAlgo ,
17
17
loadMaze ,
18
18
LOAD_MAZE ,
19
+ CHANGE_SPEED ,
20
+ handleChangeSpeed ,
21
+ UPDATE_GRID_SIZE ,
22
+ handleChangeGridSize ,
23
+ RANDOMIZE_WALLS ,
24
+ randomizeWalls ,
19
25
} from "./menuActions" ;
20
26
import { ButtonProps , DropdownProps } from "semantic-ui-react" ;
21
27
import { initialState } from "../../models/menu/initialState" ;
@@ -30,7 +36,7 @@ describe("Navbar Action Tests", () => {
30
36
} ) ;
31
37
32
38
describe ( "Start Visualization Test" , ( ) => {
33
- it ( "Should dispatch correct action" , ( ) => {
39
+ it ( "Should call START_VISUALIZATION action" , ( ) => {
34
40
const expectedActions = [
35
41
{
36
42
type : START_VISUALIZATION ,
@@ -48,7 +54,7 @@ describe("Navbar Action Tests", () => {
48
54
} ) ;
49
55
50
56
describe ( "Pause Visualization Test" , ( ) => {
51
- it ( "Should modify redux store " , ( ) => {
57
+ it ( "Should call PAUSE_VISUALIZATION action " , ( ) => {
52
58
const expectedActions = [
53
59
{
54
60
type : PAUSE_VISUALIZATION ,
@@ -66,7 +72,7 @@ describe("Navbar Action Tests", () => {
66
72
} ) ;
67
73
68
74
describe ( "Stop Visualization Test" , ( ) => {
69
- it ( "Should dispatch correct action" , ( ) => {
75
+ it ( "Should call STOP_VISUALIZATION action" , ( ) => {
70
76
const expectedActions = [
71
77
{
72
78
type : STOP_VISUALIZATION ,
@@ -84,10 +90,26 @@ describe("Navbar Action Tests", () => {
84
90
} ) ;
85
91
} ) ;
86
92
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
+ } ) ;
88
110
89
111
describe ( "Change Algorithm Test" , ( ) => {
90
- it ( "Should dispatch correct action" , ( ) => {
112
+ it ( "Should call CHANGE_ALGO action" , ( ) => {
91
113
const expectedActions = [
92
114
{
93
115
type : CHANGE_ALGO ,
@@ -104,10 +126,27 @@ describe("Navbar Action Tests", () => {
104
126
} ) ;
105
127
} ) ;
106
128
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
+ } ) ;
108
147
109
148
describe ( "Move Start Point Test" , ( ) => {
110
- it ( "Should modify redux store " , ( ) => {
149
+ it ( "Should call TOGGLE_MOVE_START action " , ( ) => {
111
150
const expectedActions = [
112
151
{
113
152
type : TOGGLE_MOVE_START ,
@@ -125,7 +164,7 @@ describe("Navbar Action Tests", () => {
125
164
} ) ;
126
165
127
166
describe ( "Move End Point Test" , ( ) => {
128
- it ( "Should modify redux store " , ( ) => {
167
+ it ( "Should call TOGGLE_MOVE_END action " , ( ) => {
129
168
const expectedActions = [
130
169
{
131
170
type : TOGGLE_MOVE_END ,
@@ -142,10 +181,21 @@ describe("Navbar Action Tests", () => {
142
181
} ) ;
143
182
} ) ;
144
183
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
+ } ) ;
146
196
147
197
describe ( "Clear Grid Test" , ( ) => {
148
- it ( "Should dispatch correct action" , ( ) => {
198
+ it ( "Should call CLEAR_GRID action" , ( ) => {
149
199
const expectedActions = [
150
200
{
151
201
type : CLEAR_GRID ,
@@ -162,8 +212,6 @@ describe("Navbar Action Tests", () => {
162
212
} ) ;
163
213
} ) ;
164
214
165
- // TODO: save maze
166
-
167
215
describe ( "Load Maze Test" , ( ) => {
168
216
it ( "Should call LOAD_MAZE action" , ( ) => {
169
217
const maze = generateMaze ( 5 , 5 , false ) ;
0 commit comments