import { MarkAsPristineAction } from '../../actions' ; import { createFormControlState } from '../../state' ; import { markAsPristineReducer } from './mark-as-pristine' ; describe ( 'form control maskAsPristineReducer' , ( ) => { const FORM_CONTROL_ID = 'test ID' ; const INITIAL_FORM_CONTROL_VALUE = '' ; const INITIAL_STATE = createFormControlState < string > ( FORM_CONTROL_ID , INITIAL_FORM_CONTROL_VALUE ) ; it ( 'should skip any actionof the wrong type' , ( ) => expect ( markAsPristineReducer ( INITIAL_STATE , { type : '' } as any ) ) . toBe ( INITIAL_STATE ) ) ; it ( 'should update state if dirty' , ( ) => { const state = { ... INITIAL_STATE , isDirty : true , isPristine : false } ; const resultState = markAsPristineReducer ( state , new MarkAsPristineAction ( FORM_CONTROL_ID ) ) ; expect ( resultState . isDirty ) . toEqual ( false ) ; expect ( resultState . isPristine ) . toEqual ( true ) ; } ) ; it ( 'should not update state if pristine' , ( ) => { const resultState = markAsPristineReducer ( INITIAL_STATE , new MarkAsPristineAction ( FORM_CONTROL_ID ) ) ; expect ( resultState ) . toBe ( INITIAL_STATE ) ; } ) ; } ) ;