Guest User

Untitled

a guest
Sep 16th, 2019
102
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export function expectAction<T>(
  2. createAction: (payload?: T) => Action | PayloadAction<T>,
  3. type: string,
  4. payload?: T
  5. ): void {
  6. const action = createAction(payload);
  7.  
  8. expect(action.type).toBe(type);
  9. if (payload) {
  10. expect((action as PayloadAction<T>).payload).toBe(payload);
  11. }
  12. }
  13.  
  14. export function expectFailureAction(
  15. actionCreator: (error: HttpErrorResponse) => any,
  16. type: string
  17. ): void {
  18. const error = new HttpErrorResponse({ error: {} });
  19. expectAction(actionCreator, type, error);
  20. }
RAW Paste Data