File tree Expand file tree Collapse file tree 2 files changed +1
-12
lines changed
Expand file tree Collapse file tree 2 files changed +1
-12
lines changed Original file line number Diff line number Diff line change @@ -6,21 +6,16 @@ import { makeAdvanceTime } from './utils/test-utils/makeAdvanceTime';
66import { makeAdvanceDateNowBy } from './utils/test-utils/makeAdvanceDateNowBy' ;
77jest . useFakeTimers ( ) ;
88const startDate = 1587574443099 ;
9- const load = jest . fn ( ) ;
109const play = jest . fn ( ) ;
1110
12- HTMLMediaElement . prototype . load = load ;
1311HTMLMediaElement . prototype . play = play ;
1412describe ( 'App' , ( ) => {
15- let load ;
1613 let play ;
1714 afterEach ( ( ) => {
1815 cleanup ( ) ;
1916 } ) ;
2017 beforeEach ( ( ) => {
21- load = jest . fn ( ) ;
2218 play = jest . fn ( ) ;
23- HTMLMediaElement . prototype . load = load ;
2419 HTMLMediaElement . prototype . play = play ;
2520 } ) ;
2621 it ( 'should run intervals correctly' , ( ) => {
@@ -104,7 +99,6 @@ describe('App', () => {
10499 for ( let i = Number ( workSecondsValue ) ; i > 0 ; i -- ) {
105100 workSecondsCountDown . next ( timeLeft . value ) ;
106101 }
107- expect ( load ) . toHaveBeenCalledTimes ( 15 ) ;
108102 expect ( play ) . toHaveBeenCalledTimes ( 15 ) ;
109103 } ) ;
110104 it ( 'should stop interval when clicking button again' , ( ) => {
@@ -161,7 +155,6 @@ describe('App', () => {
161155 prepSecondsCountDown . next ( timeLeft . value ) ;
162156 }
163157 fireEvent . click ( startButton ) ;
164- expect ( load ) . toHaveBeenCalledTimes ( 2 ) ;
165158 expect ( play ) . toHaveBeenCalledTimes ( 2 ) ;
166159 } ) ;
167160} ) ;
Original file line number Diff line number Diff line change @@ -64,10 +64,8 @@ export function useWorkoutTimer() {
6464 const shouldGetReady =
6565 status === Status . prework || status === Status . break ;
6666 if ( shouldGetReady ) {
67- beepBreak . load ( ) ;
6867 beepBreak . play ( ) ;
6968 } else {
70- beepWork . load ( ) ;
7169 beepWork . play ( ) ;
7270 }
7371 }
@@ -82,23 +80,21 @@ export function useWorkoutTimer() {
8280 statusRef . current === Status . work && roundsLeftRef . current > 0 ;
8381
8482 if ( shouldSwitchToWork ) {
85- beepBreakLong . load ( ) ;
8683 beepBreakLong . play ( ) ;
8784 setStatus ( Status . work ) ;
8885 setTimeLeft ( workInterval ) ;
8986 setRoundsLeft ( prevRoundsLeft => prevRoundsLeft - 1 ) ;
9087 } else if ( shouldSwitchToRest ) {
9188 setStatus ( Status . break ) ;
9289 setTimeLeft ( breakInterval ) ;
93- beepWorkLong . load ( ) ;
9490 beepWorkLong . play ( ) ;
9591 } else {
9692 setStatus ( Status . stopped ) ;
9793 clearInterval ( interval ) ;
9894 }
9995 }
10096 }
101- } , 100 ) ;
97+ } , 5 ) ;
10298 }
10399 return ( ) => {
104100 clearInterval ( interval ) ;
You can’t perform that action at this time.
0 commit comments