Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- getPizzas$ = this.actions$.pipe(
- ofType<GetAllPizzas>(PizzaTypes.GetPizzas,
- withLatestFrom(
- this.store$.pipe(select(fromRootStore.getPizzaId))
- ),
- take(1),
- exhaustMap(([customAction, pizzaId]): any => { // << assuming this is correct
- if (!pizzaId) {
- map(() => new BigProductError({ . /// <<< is this how we approach this? just map? or should we return something?
- appmessage : "Boom"
- }));
- } . /// <<< will control go beyond this point or is this more of an if-else condition?
- return this.pizzaService.getPizzas(customAction.orderDetails, pizzaId)
- .pipe(
- map((pizzas) => new LoadPizzasSuccess(pizzas)),
- catchError(error => of(new LoadPizzasFailure(error)))
- );
- })
- );
- describe('GetPizzas', () => {
- test(`
- Get Pizzas successfully
- `, () => {
- const action = new GetAllPizzas();
- const success = new GetAllPizzasSuccess({'NumberOfPizzas': 2});
- actions$ = hot('-a', { a: action });
- const resp = cold('-a|', { a: { NumberOfPizzas: 2 } });
- const exp = cold('--a', { a: success });
- pizzaService.getPizzas = jest.fn(() => resp);
- expect(effects.pizzaService$).toBeObservable(exp);
- });
- Expected value to equal:
- [{"frame": 20, "notification": {"error": undefined, "hasValue": true, "kind": "N", "value": {"payload": {"NumberOfPizzas": 2}, "type": "[Pizzas API] Get All Pizzas Success"}}}]
- Received:
- [{"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