Skip to content

Commit 8e4381d

Browse files
committed
unit test game flow start
1 parent 49f5620 commit 8e4381d

File tree

3 files changed

+341
-8
lines changed

3 files changed

+341
-8
lines changed

client/src/components/game/game.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,10 @@ export class Game extends React.Component {
183183
const { lastRefresh, requestAnimation, updateFloor } = this.state;
184184
const { game } = this.props;
185185
// console.log(timeStamp);
186+
187+
console.dir({ lastRefresh, timeStamp, updateFloor })
186188
if ((timeStamp - lastRefresh) >= game.timerInterval) {
189+
console.log('howdy')
187190
if (updateFloor) drawFloor(game, this.canvasContextMajor);
188191
this.setState({
189192
lastRefresh: timeStamp,
@@ -198,6 +201,7 @@ export class Game extends React.Component {
198201
};
199202

200203
endTick = (sentBy) => {
204+
console.log('In end tick')
201205
if (process.env.NODE_ENV === 'development') console.log(sentBy);
202206
this.setState({ requestAnimation: false });
203207
cancelAnimationFrame(this.animationId);

client/tests/src/components/game/__snapshots__/game.test.js.snap

Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,260 @@ exports[`The Game will display message for small screen sizes 1`] = `
99
/>
1010
</div>
1111
`;
12+
13+
exports[`The Game will display the game for allowed screen sizes 1`] = `
14+
<div
15+
id="landing"
16+
>
17+
<div
18+
className="democontainer"
19+
>
20+
<Controls
21+
allowMultiPlayer={false}
22+
difficulty={2}
23+
game={
24+
Object {
25+
"activeShape": Object {
26+
"absoluteVertices": Array [],
27+
"boundingBox": Array [],
28+
"cells": Array [],
29+
"name": "shapeZ",
30+
"rotationStage": 0,
31+
"unitBlockSize": 30,
32+
"unitVertices": Array [],
33+
"xPosition": 0,
34+
"yPosition": 0,
35+
},
36+
"canvas": Object {
37+
"canvasMajor": Object {
38+
"height": 600,
39+
"width": 300,
40+
},
41+
"canvasMinor": Object {
42+
"height": 150,
43+
"width": 210,
44+
},
45+
},
46+
"nextShape": "",
47+
"paused": true,
48+
"points": Object {
49+
"level": 0,
50+
"levelUp": 5,
51+
"totalLinesCleared": 0,
52+
},
53+
"rubble": Object {
54+
"boundaryCells": Array [
55+
"0-20",
56+
"1-20",
57+
"2-20",
58+
"3-20",
59+
"4-20",
60+
"5-20",
61+
"6-20",
62+
"7-20",
63+
"8-20",
64+
"9-20",
65+
],
66+
"occupiedCells": Array [],
67+
"winRows": null,
68+
},
69+
"timerInterval": 700,
70+
}
71+
}
72+
minorCanvas={
73+
Object {
74+
"current": Object {
75+
"focus": [MockFunction] {
76+
"calls": Array [
77+
Array [],
78+
Array [],
79+
Array [],
80+
Array [],
81+
],
82+
"results": Array [
83+
Object {
84+
"type": "return",
85+
"value": undefined,
86+
},
87+
Object {
88+
"type": "return",
89+
"value": undefined,
90+
},
91+
Object {
92+
"type": "return",
93+
"value": undefined,
94+
},
95+
Object {
96+
"type": "return",
97+
"value": undefined,
98+
},
99+
],
100+
},
101+
"getContext": [Function],
102+
"style": Object {
103+
"backgroundColor": "black",
104+
},
105+
},
106+
}
107+
}
108+
multiPlayer={
109+
Array [
110+
false,
111+
false,
112+
]
113+
}
114+
onFloorRaise={[Function]}
115+
onMultiPlayer={[Function]}
116+
onReset={[Function]}
117+
onhandlePause={[Function]}
118+
pauseButtonState={true}
119+
socketId=""
120+
/>
121+
<canvas
122+
height={600}
123+
onKeyDown={[Function]}
124+
onKeyUp={[Function]}
125+
tabIndex="0"
126+
width={300}
127+
/>
128+
<Audio
129+
clearAudio={
130+
Object {
131+
"current": Object {
132+
"focus": [MockFunction] {
133+
"calls": Array [
134+
Array [],
135+
Array [],
136+
Array [],
137+
Array [],
138+
],
139+
"results": Array [
140+
Object {
141+
"type": "return",
142+
"value": undefined,
143+
},
144+
Object {
145+
"type": "return",
146+
"value": undefined,
147+
},
148+
Object {
149+
"type": "return",
150+
"value": undefined,
151+
},
152+
Object {
153+
"type": "return",
154+
"value": undefined,
155+
},
156+
],
157+
},
158+
"getContext": [Function],
159+
"style": Object {},
160+
},
161+
}
162+
}
163+
looserAudio={
164+
Object {
165+
"current": Object {
166+
"focus": [MockFunction] {
167+
"calls": Array [
168+
Array [],
169+
Array [],
170+
Array [],
171+
Array [],
172+
],
173+
"results": Array [
174+
Object {
175+
"type": "return",
176+
"value": undefined,
177+
},
178+
Object {
179+
"type": "return",
180+
"value": undefined,
181+
},
182+
Object {
183+
"type": "return",
184+
"value": undefined,
185+
},
186+
Object {
187+
"type": "return",
188+
"value": undefined,
189+
},
190+
],
191+
},
192+
"getContext": [Function],
193+
"style": Object {},
194+
},
195+
}
196+
}
197+
maxClearAudio={
198+
Object {
199+
"current": Object {
200+
"focus": [MockFunction] {
201+
"calls": Array [
202+
Array [],
203+
Array [],
204+
Array [],
205+
Array [],
206+
],
207+
"results": Array [
208+
Object {
209+
"type": "return",
210+
"value": undefined,
211+
},
212+
Object {
213+
"type": "return",
214+
"value": undefined,
215+
},
216+
Object {
217+
"type": "return",
218+
"value": undefined,
219+
},
220+
Object {
221+
"type": "return",
222+
"value": undefined,
223+
},
224+
],
225+
},
226+
"getContext": [Function],
227+
"style": Object {},
228+
},
229+
}
230+
}
231+
winnerAudio={
232+
Object {
233+
"current": Object {
234+
"focus": [MockFunction] {
235+
"calls": Array [
236+
Array [],
237+
Array [],
238+
Array [],
239+
Array [],
240+
],
241+
"results": Array [
242+
Object {
243+
"type": "return",
244+
"value": undefined,
245+
},
246+
Object {
247+
"type": "return",
248+
"value": undefined,
249+
},
250+
Object {
251+
"type": "return",
252+
"value": undefined,
253+
},
254+
Object {
255+
"type": "return",
256+
"value": undefined,
257+
},
258+
],
259+
},
260+
"getContext": [Function],
261+
"style": Object {},
262+
},
263+
}
264+
}
265+
/>
266+
</div>
267+
</div>
268+
`;

0 commit comments

Comments
 (0)