16. Update reducer tests

In this little section we will update our reducer tests to use our new types.

1. Use action creators in our reducer tests

  • Type our fake effect as an any to trick the TypeScript compiler and also add a StartSpinner action creator to the other test.

src/app/state/spinner/reducer.spec.ts
import { reducer } from './spinner.reducer';
import { StartSpinner } from './spinner.actions';

describe('Reducer: Spinner', () => {
  it('should have initial state of isOn false', () => {
    const expected = { isOn: false };
    const action = { type: 'foo' } as any;
    expect(reducer(undefined, action)).toEqual(expected);
  });

  it('should have a isOn set to true', () => {
    const initialState = { isOn: false };
    const action = new StartSpinner();
    const expected = { isOn: true };
    expect(reducer(initialState, action)).toEqual(expected);
  });
});

Last updated