import { initialState, reducer } from '../components/user_summary/shipping_address/ShippingAddressReducer'; import Addresses from './mock/Addresses.json'; import Countries from './mock/Countries.json'; describe('ShippingAddressReducer', () => { test('sets addresses', () => { const state = reducer(initialState, ['SetAddresses', Addresses]); expect(state.addresses).toStrictEqual(Addresses); }); test('sets current view', () => { const state = reducer(initialState, ['SetCurrentView', 'list']); expect(state.currentView).toEqual('list'); }); test('sets loading label', () => { const state = reducer(initialState, ['SetLoadingLabel', 'loading']); expect(state.loadingLabel).toEqual('loading'); }); test('clears loading label', () => { const state = reducer(initialState, ['ClearLoadingLabel']); expect(state.loadingLabel).toEqual(''); }); test('sets current state', () => { const stateObj = {label: 'Idaho', value: 'io'}; const state = reducer(initialState, ['SetCurrentState', stateObj]); expect(state.currentState).toEqual(stateObj); }); test('sets current country', () => { const state = reducer(initialState, ['SetCurrentCountry', Countries[1]]); expect(state.currentCountry).toEqual(Countries[1]); }); test('sets modal addresses', () => { const modalAddresses = { validated: Addresses[1], nonValidated: Addresses[0] }; const state = reducer(initialState, ['SetModalAddresses', modalAddresses]); expect(state.modalAddresses).toEqual(modalAddresses); }); test('sets current selection ID', () => { const state = reducer(initialState, ['SetCurrentSelectionId', 8675309]); expect(state.currentSelectionId).toEqual(8675309); }); });