Angular and NgRx
  • Introduction
  • Setup
  • 1. Create an application
  • 2. Create a home component
  • 3. Test HomeComponent
  • 4. Create event feature module
  • 5.Create AddAttendeeComponent
  • 6. Test AddAttendeeComponent
  • 7. Listen to child component events
  • 8. Add test for the event emitter
  • 9. Create EventListComponent
  • 10. Test EventListComponent
  • 11. Create EventService
  • 12. Test EventService
  • 13. Add simple NgRx spinner
  • 14. Test reducer
  • 15. Strongly type our store
  • 16. Update reducer tests
  • 17. Store dev tools
  • 18. Create selectors
  • 19. Create feature state
  • 20. Create effect
  • 21. Test an effect
  • 22. Use Entity Adapter
  • 23. Add attendee logic
  • 24. Router store
  • 25. Fix EventComponent tests
Powered by GitBook
On this page
  • 1. Use action creators in our reducer tests
  • StackBlitz Link

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);
  });
});

StackBlitz Link

Previous15. Strongly type our storeNext17. Store dev tools

Last updated 6 years ago

Duncanhunter - Angular And Ngrx Demo App - StackBlitzStackBlitz
Web Link: Link to the demo app running in StackBlitz
Logo