Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. getPizzas$ = this.actions$.pipe(
  2. ofType<GetAllPizzas>(PizzaTypes.GetPizzas,
  3. withLatestFrom(
  4. this.store$.pipe(select(fromRootStore.getPizzaId))
  5. ),
  6. take(1),
  7. exhaustMap(([customAction, pizzaId]): any => { // << assuming this is correct
  8. if (!pizzaId) {
  9. map(() => new BigProductError({ . /// <<< is this how we approach this? just map? or should we return something?
  10. appmessage : "Boom"
  11. }));
  12. } . /// <<< will control go beyond this point or is this more of an if-else condition?
  13. return this.pizzaService.getPizzas(customAction.orderDetails, pizzaId)
  14. .pipe(
  15. map((pizzas) => new LoadPizzasSuccess(pizzas)),
  16. catchError(error => of(new LoadPizzasFailure(error)))
  17. );
  18. })
  19. );
  20.  
  21. describe('GetPizzas', () => {
  22. test(`
  23. Get Pizzas successfully
  24. `, () => {
  25. const action = new GetAllPizzas();
  26. const success = new GetAllPizzasSuccess({'NumberOfPizzas': 2});
  27.  
  28. actions$ = hot('-a', { a: action });
  29. const resp = cold('-a|', { a: { NumberOfPizzas: 2 } });
  30. const exp = cold('--a', { a: success });
  31. pizzaService.getPizzas = jest.fn(() => resp);
  32.  
  33. expect(effects.pizzaService$).toBeObservable(exp);
  34. });
  35.  
  36. Expected value to equal:
  37. [{"frame": 20, "notification": {"error": undefined, "hasValue": true, "kind": "N", "value": {"payload": {"NumberOfPizzas": 2}, "type": "[Pizzas API] Get All Pizzas Success"}}}]
  38. Received:
  39. [{"frame": 20, "notification": {"error": undefined, "hasValue": true, "kind": "N", "value": {"payload": {"NumberOfPizzas": 2}, "type": "[[Pizzas API] Get All Pizzas Success"}}}, {"frame": 30, "notification": {"error": undefined, "hasValue": false, "kind": "C", "value": undefined}}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement