import { setContactContent } from './contact.actions'; import { contactReducer } from './contact.reducer'; import { ContactState } from './contact.types'; describe('Contact reducer tests', () => { let initialState: ContactState = { sections: [], }; function createMockContact(id) { return { pool: `Pool ${id}`, thumbnail: `thumbnail ${id}`, name: `Name ${id}`, position: `Position ${id}`, phone: `Phone ${id}`, email: `Email ${id}`, }; } it('returns the initial state', () => { expect(contactReducer(undefined, { type: 'testString' })).toEqual(initialState); }); it('sets contacts state when setContactContent is fired', () => { const contactPage = { sections: [ { title: 'Test', contacts: [ createMockContact(1), createMockContact(2), createMockContact(3), ], }, ], }; const expectedState = { ...initialState, ...contactPage, }; const action = setContactContent(contactPage); expect(contactReducer(initialState, action)).toEqual(expectedState); }); });