import { act } from 'react-dom/test-utils' ; import { setupEnvironment } from '../../helpers' ; import { setupTimingTestBed , TimingTestBed } from './timing.helpers' ; import { PhaseWithTiming } from '../../../../common/types' ; describe ( '<EditPolicy /> timing' , ( ) => { let testBed ; const { server , httpRequestsMockHelpers } = setupEnvironment ( ) ; afterAll ( ( ) => { server . restore ( ) ; } ) ; beforeEach ( async ( ) => { httpRequestsMockHelpers . setDefaultResponses ( ) ; await act ( async ( ) => { testBed = await setupTimingTestBed ( ) ; } ) ; const { component } = testBed ; component . update ( ) ; } ) ; [ 'warm' , 'cold' , 'frozen' , 'delete' ] . forEach ( ( phase ) => { test ( `timing is only shown when ${ phase } phase is enabled` , async ( ) => { const { actions } = testBed ; const phaseWithTiming = phase as PhaseWithTiming ; expect ( actions [ phaseWithTiming ] . hasMinAgeInput ( ) ) . toBeFalsy ( ) ; await actions . togglePhase ( phaseWithTiming ) ; expect ( actions [ phaseWithTiming ] . hasMinAgeInput ( ) ) . toBeTruthy ( ) ; } ) ; } ) ; } ) ;