How to use jest-marbles - 10 common examples

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 / 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 / core / store / shopping / categories / categories.effects.spec.ts View on Github external
it('should map invalid request to action of type LoadCategoryFail', () => {
      const categoryId = 'invalid';
      const action = new fromActions.LoadCategory({ categoryId });
      const completion = new fromActions.LoadCategoryFail({ error: { message: 'invalid category' } as HttpError });
      actions$ = hot('-a-a-a', { a: action });
      const expected$ = cold('-c-c-c', { c: completion });

      expect(effects.loadCategory$).toBeObservable(expected$);
    });
  });
github intershop / intershop-pwa / src / app / extensions / quoting / services / quote-request / quote-request.service.spec.ts View on Github external
it('should throw error for deleteQuoteRequest', () => {
      expect(quoteRequestService.deleteQuoteRequest(undefined)).toBeObservable(
        cold('#', undefined, { message: 'not logged in' })
      );
    });
github intershop / intershop-pwa / src / app / core / store / shopping / categories / categories.effects.spec.ts View on Github external
it('should not fire when selected category is available but not completely loaded', () => {
      store$.dispatch(
        new fromActions.LoadCategorySuccess({ categories: categoryTree([{ uniqueId: 'A' }] as Category[]) })
      );
      store$.dispatch(new fromActions.SelectCategory({ categoryId: 'A' }));

      actions$ = of(new fromActions.SelectCategory({ categoryId: 'A' }));

      expect(effects.selectedCategoryAvailable$).toBeObservable(cold('-----'));
    });
github intershop / intershop-pwa / src / app / extensions / quoting / services / quote-request / quote-request.service.spec.ts View on Github external
it("should throw error if 'setQuoteRequestItems' is called with unsubmitted quote request", () => {
      expect(
        quoteRequestService.createQuoteRequestFromQuoteRequest({ submitted: false, items: [] } as QuoteRequest)
      ).toBeObservable(
        cold('#', undefined, { message: 'createQuoteRequestFromQuoteRequest() called with unsubmitted quote request' })
      );
    });
github intershop / intershop-pwa / src / app / core / store / shopping / viewconf / viewconf.effects.spec.ts View on Github external
it('should do nothing if no category is selected', () => {
      const action = new ChangeSortBy({ sorting: 'name-desc' });
      actions$ = hot('-a-a-a', { a: action });
      expect(effects.changeSortBy$).toBeObservable(cold('-'));
    });
github intershop / intershop-pwa / src / app / core / store / orders / orders.effects.spec.ts View on Github external
it('should not trigger SelectOrderAfterRedirect action if checkout payment/receipt page is called with query param "redirect" and there is no logged in user and no order', () => {
      const action = new RouteNavigation({
        path: 'checkout/receipt',
        queryParams: { redirect: 'success', param1: 123, orderId: order.id },
      });
      actions$ = hot('-a', { a: action });

      expect(effects.returnFromRedirectAfterOrderCreation$).toBeObservable(cold('-'));
    });
github intershop / intershop-pwa / src / app / core / store / content / pages / pages.effects.spec.ts View on Github external
it('should not die when encountering an error', () => {
      when(cmsServiceMock.getContentPage('dummy')).thenReturn(throwError({ message: 'ERROR' }));

      actions$ = hot('a-a-a-a', { a: new LoadContentPage({ contentPageId: 'dummy' }) });

      expect(effects.loadContentPage$).toBeObservable(
        cold('a-a-a-a', { a: new LoadContentPageFail({ error: { message: 'ERROR' } as HttpError }) })
      );
    });
  });
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$);
    });
  });

jest-marbles

Marble testing helpers library for RxJs and Jest

MIT
Latest version published 5 months ago

Package Health Score

77 / 100
Full package analysis

Popular jest-marbles functions