| import * as fromReducer from '@shared/store/reducers/admin/person-types-details-form.reducer'; |
| import { PersonType } from '@shared/models'; |
| import { Action } from '@ngrx/store'; |
| import { FormGroupState } from 'ngrx-forms'; |
| import * as personTypesActions from '@shared/store/actions/admin/person-types.action'; |
| |
| describe('PersonType Detail Form reducer', () => { |
| const { INITIAL_STATE } = fromReducer; |
| |
| it('should return the default state when no state is given', () => { |
| const action: Action = { type: '' }; |
| const state: FormGroupState<PersonType> = fromReducer.reducer(undefined, action); |
| |
| expect(state).toBe(INITIAL_STATE); |
| }); |
| |
| it('should return the initial state when action is not found', () => { |
| const action: Action = { type: '' }; |
| const state: FormGroupState<PersonType> = fromReducer.reducer(INITIAL_STATE, action); |
| |
| expect(state).toBe(INITIAL_STATE); |
| }); |
| |
| it('should return the initial state when no action set', () => { |
| const action: Action = null; |
| const state: FormGroupState<PersonType> = fromReducer.reducer(INITIAL_STATE, action); |
| |
| expect(state).toBe(INITIAL_STATE); |
| }); |
| |
| it('should return state via getFormState', () => { |
| const action: Action = null; |
| const state: FormGroupState<PersonType> = fromReducer.reducer(INITIAL_STATE, action); |
| expect(fromReducer.getFormState(state)).toBe(state); |
| }); |
| |
| it('should set id', () => { |
| const action: Action = { type: personTypesActions.loadPersonTypeSuccess.type }; |
| action['payload']={id: 'x'}; |
| const state: FormGroupState<PersonType> = fromReducer.reducer(INITIAL_STATE, action); |
| expect(state.controls.id).toBeDefined(); |
| }); |
| |
| }); |