Skip to content

Commit

Permalink
update tests and fix issue with test
Browse files Browse the repository at this point in the history
  • Loading branch information
crystalclear506 committed Aug 23, 2021
1 parent d514574 commit 3d2e756
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 27 deletions.
11 changes: 5 additions & 6 deletions src/Components/countdown-clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ class CountdownClock extends React.Component {
super(props);

this.state = {
secondsDisp: '',
minutesDisp: '',
hoursDisp: '',
daysDisp: '',
milisDisp: '',
secondsDisp: '00',
minutesDisp: '00',
hoursDisp: '00',
daysDisp: '0',
milisDisp: '00',
endTime: null,
isTimeout: false,
};
this.initializeClock();
}

setCountdownEnd(endTime) {
Expand Down
45 changes: 26 additions & 19 deletions tests/__snapshots__/countdown-clock.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,51 @@ exports[`Component should be rendered correctly 1`] = `
>
<div
className="cell"
>
00
</div>
<div
className="colons"
>
<div>
:
0
</div>
<div
className="label"
>
Days
</div>
</div>
<div
className="cell"
>
00
</div>
<div
className="colons"
>
<div>
:
00
</div>
<div
className="label"
>
Hours
</div>
</div>
<div
className="cell"
>
00
</div>
<div
className="colons"
>
<div>
:
00
</div>
<div
className="label"
>
Minutes
</div>
</div>
<div
className="cell"
>
000
<div>
00
</div>
<div
className="label"
>
Seconds
</div>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions tests/countdown-clock.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ test('Countdown should decrement correctly', (done) => {


setTimeout(() => {
expect(component.state.secondsDisp).toBe(30);
expect(component.state.secondsDisp).toBe("30");
}, seconds / 2);

setTimeout(() => {
expect(component.state.secondsDisp).toBe(0);
expect(component.state.secondsDisp).toBe("00");
}, seconds);

jest.runAllTimers();
Expand Down

0 comments on commit 3d2e756

Please sign in to comment.