@@ -193,4 +193,78 @@ describe('App', () => {
193193 fireEvent . click ( startButton ) ;
194194 expect ( play ) . toHaveBeenCalledTimes ( 2 ) ;
195195 } ) ;
196+
197+ it . each `
198+ case | workMinutesValue | workSecondsValue | breakMinutesValue | breakSecondsValue
199+ ${ 'work input empty' } | ${ '0' } | ${ '0' } | ${ '1' } | ${ '1' }
200+ ${ 'break input empty' } | ${ '1' } | ${ '1' } | ${ '0' } | ${ '0' }
201+ ` (
202+ 'should not run when $case' ,
203+ ( {
204+ workMinutesValue,
205+ workSecondsValue,
206+ breakMinutesValue,
207+ breakSecondsValue,
208+ } ) => {
209+ const {
210+ breakIntervalMinuteInput,
211+ breakIntervalSecondInput,
212+ prepTime,
213+ roundInput,
214+ startButton,
215+ workIntervalMinuteInput,
216+ workIntervalSecondInput,
217+ getByTestId,
218+ getByText,
219+ } = renderApp ( ) ;
220+
221+ expect ( roundInput ) . toBeTruthy ( ) ;
222+ expect ( workIntervalMinuteInput ) . toBeTruthy ( ) ;
223+ expect ( workIntervalSecondInput ) . toBeTruthy ( ) ;
224+ expect ( breakIntervalMinuteInput ) . toBeTruthy ( ) ;
225+ expect ( breakIntervalSecondInput ) . toBeTruthy ( ) ;
226+ expect ( startButton ) . toBeTruthy ( ) ;
227+
228+ const roundsValue = '2' ;
229+
230+ fireEvent . change ( roundInput , { target : { value : roundsValue } } ) ;
231+ fireEvent . blur ( roundInput ) ;
232+
233+ fireEvent . change ( workIntervalMinuteInput , {
234+ target : { value : workMinutesValue } ,
235+ } ) ;
236+ fireEvent . change ( workIntervalSecondInput , {
237+ target : { value : workSecondsValue } ,
238+ } ) ;
239+
240+ fireEvent . change ( breakIntervalMinuteInput , {
241+ target : { value : breakMinutesValue } ,
242+ } ) ;
243+ fireEvent . change ( breakIntervalSecondInput , {
244+ target : { value : breakSecondsValue } ,
245+ } ) ;
246+
247+ const advanceDateNowBy = makeAdvanceDateNowBy ( startDate ) ;
248+
249+ fireEvent . click ( startButton ) ;
250+
251+ const timeLeftSeconds = getByTestId ( 'time-left-seconds' ) ;
252+ const round = getByTestId ( 'round' ) ;
253+ const status = getByTestId ( 'status' ) ;
254+
255+ expect ( round . textContent ) . toBe ( '0/2' ) ;
256+ expect ( status . textContent ) . toBe ( 'PREP' ) ;
257+
258+ // count down from 00:05 and stop after two seconds
259+ expectCountDownFrom ( {
260+ minutes : 0 ,
261+ seconds : prepTime ,
262+ advanceDateNowBy,
263+ timeLeftMinutes : { value : '00' } ,
264+ timeLeftSeconds,
265+ } ) ;
266+
267+ expect ( getByText ( 'Start' ) ) . toBeTruthy ( ) ;
268+ }
269+ ) ;
196270} ) ;
0 commit comments