@@ -2,7 +2,7 @@ import React from "react";
2
2
import { Provider } from "react-redux" ;
3
3
import configureStore from "redux-mock-store" ;
4
4
import { mount } from "../../setupTests" ;
5
- import Menu , { MenuProps } from "." ;
5
+ import Menu , { Props } from "." ;
6
6
import { initialState } from "../../models/maze/initialState" ;
7
7
import { initialState as MenuInitialState } from "../../models/menu/initialState" ;
8
8
import {
@@ -17,10 +17,10 @@ const mockStore = configureStore();
17
17
describe ( "<Menu />" , ( ) => {
18
18
let wrapper : any ;
19
19
20
- const props : MenuProps = {
20
+ const props : Props = {
21
21
canMoveStart : false ,
22
22
canMoveEnd : false ,
23
- selectedAlgo : undefined ,
23
+ selectedAlgo : "A*" ,
24
24
algorithms : [
25
25
{ value : "A*" , text : "A*" } ,
26
26
{ value : "Djikstras" , text : "Djikstras" } ,
@@ -36,15 +36,14 @@ describe("<Menu />", () => {
36
36
onClear : jest . fn ( ) ,
37
37
toggleMoveStart : jest . fn ( ) ,
38
38
toggleMoveEnd : jest . fn ( ) ,
39
- saveMaze : jest . fn ( ) ,
40
39
loadMaze : jest . fn ( ) ,
41
40
handleDropdownSpeed : jest . fn ( ) ,
42
41
randomizeWalls : jest . fn ( ) ,
43
42
playSpeeds : MenuInitialState . playSpeeds ,
44
43
startTime : undefined ,
45
44
endTime : undefined ,
46
45
currentSpeed : 1 ,
47
- updateGridSize : jest . fn ( ) ,
46
+ handleChangeGridSize : jest . fn ( ) ,
48
47
} ;
49
48
50
49
it ( "defines the component" , ( ) => {
@@ -60,9 +59,9 @@ describe("<Menu />", () => {
60
59
it ( "Menu renders with icons" , ( ) => {
61
60
expect ( wrapper . find ( SemanticMenu ) ) . toBeDefined ( ) ;
62
61
expect ( wrapper . find ( SemanticMenu . Item ) ) . toBeDefined ( ) ;
63
- expect ( wrapper . find ( SemanticMenu . Item ) ) . toHaveLength ( 5 ) ;
62
+ expect ( wrapper . find ( SemanticMenu . Item ) ) . toHaveLength ( 4 ) ;
64
63
expect ( wrapper . find ( SemanticIcon ) ) . toBeDefined ( ) ;
65
- expect ( wrapper . find ( SemanticIcon ) ) . toHaveLength ( 12 ) ;
64
+ expect ( wrapper . find ( SemanticIcon ) ) . toHaveLength ( 13 ) ;
66
65
} ) ;
67
66
68
67
it ( "Dropdown renders" , ( ) => {
@@ -71,7 +70,7 @@ describe("<Menu />", () => {
71
70
72
71
it ( "Buttons render" , ( ) => {
73
72
expect ( wrapper . find ( SemanticButton ) ) . toBeDefined ( ) ;
74
- expect ( wrapper . find ( SemanticButton ) ) . toHaveLength ( 10 ) ;
73
+ expect ( wrapper . find ( SemanticButton ) ) . toHaveLength ( 11 ) ;
75
74
} ) ;
76
75
77
76
it ( "Play button calls action" , ( ) => {
@@ -97,22 +96,22 @@ describe("<Menu />", () => {
97
96
} ) ;
98
97
99
98
it ( "Move Start Point button calls action" , ( ) => {
100
- wrapper . find ( SemanticButton ) . at ( 3 ) . simulate ( "click" ) ;
99
+ wrapper . find ( SemanticButton ) . at ( 8 ) . simulate ( "click" ) ;
101
100
expect ( props . toggleMoveStart ) . toHaveBeenCalled ( ) ;
102
101
} ) ;
103
102
104
103
it ( "Move End Point button calls action" , ( ) => {
105
- wrapper . find ( SemanticButton ) . at ( 4 ) . simulate ( "click" ) ;
104
+ wrapper . find ( SemanticButton ) . at ( 9 ) . simulate ( "click" ) ;
106
105
expect ( props . toggleMoveEnd ) . toHaveBeenCalled ( ) ;
107
106
} ) ;
108
107
109
- it ( "Clear button calls action" , ( ) => {
110
- wrapper . find ( SemanticButton ) . at ( 5 ) . simulate ( "click" ) ;
108
+ it ( "Randomize walls button calls action" , ( ) => {
109
+ wrapper . find ( SemanticButton ) . at ( 2 ) . simulate ( "click" ) ;
111
110
expect ( props . randomizeWalls ) . toHaveBeenCalled ( ) ;
112
111
} ) ;
113
112
114
113
it ( "Clear button calls action" , ( ) => {
115
- wrapper . find ( SemanticButton ) . at ( 6 ) . simulate ( "click" ) ;
114
+ wrapper . find ( SemanticButton ) . at ( 3 ) . simulate ( "click" ) ;
116
115
expect ( props . onClear ) . toHaveBeenCalled ( ) ;
117
116
} ) ;
118
117
0 commit comments