import { act } from 'react-dom/test-utils' ; import { setupEnvironment } from '../../helpers' ; import { setupTimelineTestBed , TimelineTestBed } from './timeline.helpers' ; describe ( '<EditPolicy /> timeline' , ( ) => { let testBed ; const { server , httpRequestsMockHelpers } = setupEnvironment ( ) ; afterAll ( ( ) => { server . restore ( ) ; } ) ; beforeEach ( async ( ) => { httpRequestsMockHelpers . setDefaultResponses ( ) ; await act ( async ( ) => { testBed = await setupTimelineTestBed ( ) ; } ) ; const { component } = testBed ; component . update ( ) ; } ) ; test ( 'showing all phases on the timeline' , async ( ) => { const { actions } = testBed ; expect ( actions . timeline . hasPhase ( 'hot' ) ) . toBe ( true ) ; expect ( actions . timeline . hasPhase ( 'warm' ) ) . toBe ( false ) ; expect ( actions . timeline . hasPhase ( 'cold' ) ) . toBe ( false ) ; expect ( actions . timeline . hasPhase ( 'delete' ) ) . toBe ( false ) ; await actions . togglePhase ( 'warm' ) ; expect ( actions . timeline . hasPhase ( 'hot' ) ) . toBe ( true ) ; expect ( actions . timeline . hasPhase ( 'warm' ) ) . toBe ( true ) ; expect ( actions . timeline . hasPhase ( 'cold' ) ) . toBe ( false ) ; expect ( actions . timeline . hasPhase ( 'delete' ) ) . toBe ( false ) ; await actions . togglePhase ( 'cold' ) ; expect ( actions . timeline . hasPhase ( 'hot' ) ) . toBe ( true ) ; expect ( actions . timeline . hasPhase ( 'warm' ) ) . toBe ( true ) ; expect ( actions . timeline . hasPhase ( 'cold' ) ) . toBe ( true ) ; expect ( actions . timeline . hasPhase ( 'delete' ) ) . toBe ( false ) ; await actions . togglePhase ( 'delete' ) ; expect ( actions . timeline . hasPhase ( 'hot' ) ) . toBe ( true ) ; expect ( actions . timeline . hasPhase ( 'warm' ) ) . toBe ( true ) ; expect ( actions . timeline . hasPhase ( 'cold' ) ) . toBe ( true ) ; expect ( actions . timeline . hasPhase ( 'delete' ) ) . toBe ( true ) ; } ) ; } ) ;