How to use the jest-marbles.hot function in jest-marbles

To help you get started, we’ve selected a few jest-marbles examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github intershop / intershop-pwa / src / app / core / store / countries / countries.effects.spec.ts View on Github external
it('should load all countries on effects init and dispatch a LoadCountriesSuccess action', () => {
      const action = { type: CountryActionTypes.LoadCountries } as Action;
      const expected = new LoadCountriesSuccess({ countries });

      actions$ = hot('-a-------', { a: action });

      expect(effects.loadCountries$).toBeObservable(cold('-b-------', { b: expected }));
    });
github intershop / intershop-pwa / src / app / core / store / checkout / basket / basket-items.effects.spec.ts View on Github external
it('should accumulate AddProductToBasket to a single AddItemsToBasket action', () => {
      store$.dispatch(new LoadProductSuccess({ product: { sku: 'SKU1', packingUnit: 'pcs.' } as Product }));
      store$.dispatch(new LoadProductSuccess({ product: { sku: 'SKU2', packingUnit: 'pcs.' } as Product }));
      const action1 = new basketActions.AddProductToBasket({ sku: 'SKU1', quantity: 1 });
      const action2 = new basketActions.AddProductToBasket({ sku: 'SKU2', quantity: 1 });
      const completion = new basketActions.AddItemsToBasket({
        items: [{ sku: 'SKU2', quantity: 2, unit: 'pcs.' }, { sku: 'SKU1', quantity: 2, unit: 'pcs.' }],
      });
      actions$ = hot('        -b-a-b-a--|', { a: action1, b: action2 });
      const expected$ = cold('----------(c|)', { c: completion });

      expect(effects.addProductToBasket$).toBeObservable(expected$);
    });
  });
github intershop / intershop-pwa / src / app / extensions / quoting / store / quote / quote.effects.spec.ts View on Github external
it('should map to action of type LoadQuotes if SubmitQuoteRequestSuccess action triggered', () => {
      const action = new SubmitQuoteRequestSuccess(anyString());
      const completion = new quoteActions.LoadQuotes();
      actions$ = hot('-a-a-a', { a: action });
      const expected$ = cold('-c-c-c', { c: completion });

      expect(effects.loadQuotesAfterChangeSuccess$).toBeObservable(expected$);
    });
github intershop / intershop-pwa / src / app / core / store / shopping / promotions / promotions.effects.spec.ts View on Github external
it('should map invalid request to action of type LoadPromotionFail only once', () => {
      const promoId = 'invalid';
      const action = new fromActions.LoadPromotion({ promoId });
      const completion = new fromActions.LoadPromotionFail({ error: { message: 'invalid' } as HttpError, promoId });
      actions$ = hot('-a-a-a', { a: action });
      const expected$ = cold('-c----', { c: completion });

      expect(effects.loadPromotion$).toBeObservable(expected$);
    });
  });
github intershop / intershop-pwa / src / app / core / store / shopping / products / products.effects.spec.ts View on Github external
it('should trigger LoadProduct action if LoadProductSuccess contains productMasterSKU', () => {
      const action = new fromActions.LoadProductSuccess({
        product: {
          productMasterSKU: 'MSKU',
          type: 'VariationProduct',
        } as VariationProduct,
      });
      const completion = new fromActions.LoadProductIfNotLoaded({ sku: 'MSKU', level: ProductCompletenessLevel.List });
      actions$ = hot('-a', { a: action });
      const expected$ = cold('-c', { c: completion });

      expect(effects.loadMasterProductForProduct$).toBeObservable(expected$);
    });
github intershop / intershop-pwa / src / app / core / store / shopping / recently / recently.effects.spec.ts View on Github external
it('should not fire when product is not yet loaded', () => {
      actions$ = hot('a', { a: new SelectProduct({ sku: 'A' }) });

      expect(effects.viewedProduct$).toBeObservable(cold('------'));
    });
github intershop / intershop-pwa / src / app / core / store / checkout / basket / basket-payment.effects.spec.ts View on Github external
it('should map to action of type LoadBasket in case of success', () => {
      const action = new basketActions.UpdateBasketPaymentSuccess();
      const completion = new basketActions.LoadBasket();
      actions$ = hot('-a-a-a', { a: action });
      const expected$ = cold('-c-c-c', { c: completion });

      expect(effects.loadBasketAfterBasketChangeSuccess$).toBeObservable(expected$);
    });
  });
github intershop / intershop-pwa / src / app / core / store / shopping / filter / filter.effects.spec.ts View on Github external
it('should map to action of type LoadFilterSuccess', () => {
      const action = new fromActions.LoadFilterForCategory({ uniqueId: 'c' });
      const completion = new fromActions.LoadFilterSuccess({ filterNavigation: filterNav });
      actions$ = hot('-a-a-a', { a: action });
      const expected$ = cold('-c-c-c', { c: completion });

      expect(effects.loadAvailableFilterForCategories$).toBeObservable(expected$);
    });
github intershop / intershop-pwa / src / app / core / store / user / user.effects.spec.ts View on Github external
it('should call the user service on LoadUserByAPIToken action and do nothing when failing', () => {
      when(userServiceMock.signinUserByToken('dummy')).thenReturn(EMPTY);

      actions$ = hot('a-a-a-', { a: new ua.LoadUserByAPIToken({ apiToken: 'dummy' }) });

      expect(effects.loadUserByAPIToken$).toBeObservable(cold('------'));
    });
  });
github intershop / intershop-pwa / src / app / core / store / shopping / filter / filter.effects.spec.ts View on Github external
value: 'test',
          filters: 'b*',
        },
        searchParameter: 'b',
      });
      const completion = new SetProductListingPages({
        id: {
          type: 'search',
          value: 'test',
          filters: 'b*',
        },
        1: ['123', '234'],
        itemCount: 2,
        sortKeys: [],
      });
      actions$ = hot('        -a-b-|', { a: routing, b: action });
      const expected$ = cold('---c-|', { c: completion });
      expect(effects.loadFilteredProducts$).toBeObservable(expected$);
    });
  });

jest-marbles

Marble testing helpers library for RxJs and Jest

MIT
Latest version published 4 months ago

Package Health Score

77 / 100
Full package analysis

Popular jest-marbles functions