How to use jasmine-marbles - 10 common examples

To help you get started, we’ve selected a few jasmine-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 angular / angular / aio / content / examples / testing / src / app / twain / twain.component.marbles.spec.ts View on Github external
it('should show quote after getQuote (marbles)', () => {
    // observable test quote value and complete(), after delay
    // #docregion test-quote-marbles
    const q$ = cold('---x|', { x: testQuote });
    // #enddocregion test-quote-marbles
    getQuoteSpy.and.returnValue( q$ );

    fixture.detectChanges(); // ngOnInit()
    expect(quoteEl.textContent).toBe('...', 'should show placeholder');

    // #docregion test-scheduler-flush
    getTestScheduler().flush(); // flush the observables
    // #enddocregion test-scheduler-flush

    fixture.detectChanges(); // update view

    expect(quoteEl.textContent).toBe(testQuote, 'should show quote');
    expect(errorMessage()).toBeNull('should not show error');
  });
  // #enddocregion get-quote-test
github opfab / operatorfabric-core / ui / main / src / app / store / effects / config.effects.spec.ts View on Github external
it('should return a LoadConfigsSuccess when the configService serve configuration', () => {
            const expectedConfig = {value: {subValue1: 1, subValue2: 2}};

            const localActions$ = new Actions(hot('-a--', {a: new LoadConfig()}));

            // const localMockConfigService = jasmine.createSpyObj('ConfigService', ['fetchConfiguration']);

            configService.fetchConfiguration.and.returnValue(hot('---b', {b: expectedConfig}));
            const expectedAction = new LoadConfigSuccess({config: expectedConfig});
            const localExpected = hot('---c', {c: expectedAction});

            effects = new ConfigEffects(mockStore, localActions$, configService);

            expect(effects).toBeTruthy();
            expect(effects.loadConfiguration).toBeObservable(localExpected);
        });
        it('should return a LoadConfigsFailure when the configService doesn\'t serve configuration', () => {
github opfab / operatorfabric-core / ui / main / src / app / store / effects / custom-router.effects.spec.ts View on Github external
it('should trigger ClearLightCardSelection if navigating from feed/cards/* to somewhere else', () => {

            const navigation = {
                type: ROUTER_REQUEST,
                payload: {
                    routerState: {
                        url: "/feed/cards/myCardId"
                    },
                    event: new NavigationStart(1,"/archive/")
                }
            }

            const localActions$ = new Actions(hot('-a-', { a: navigation}));

            const expectedAction = new ClearLightCardSelection();
            const localExpected = hot('-b-', {b: expectedAction});

            effects = new CustomRouterEffects(mockStore, localActions$);

            expect(effects).toBeTruthy();
            expect(effects.navigateAwayFromFeed).toBeObservable(localExpected);

        });
github GetTerminus / ngx-tools / ngx-tools / utilities / src / http-retryer / http-retryer.spec.ts View on Github external
test(`should handle a delay with a specific retry date time`, () => {
      const waitTime = time(`${'-'.repeat(100)  }|`);
      const emissionTime = new Date(getTestScheduler().now() + waitTime);

      const retryErrorWithSpecificDelay = new HttpErrorResponse({
        status: 429,
        headers: new HttpHeaders({ 'Retry-After': emissionTime.toString() }),
      });

      getTestScheduler().maxFrames = 1500;

      (expect(
        errorAfter(3, retryErrorWithSpecificDelay, 1).pipe(
          httpRetryer({ scheduler: getTestScheduler() }),
        ),
      ) as any).toBeObservable(
        // Note the '- 2' account for the time it takes to get to the first error
        cold(`ab${  '-'.repeat(100 - 2)  }abcd`, {
          a: 1,
          b: 2,
          c: 3,
          d: 4,
        }),
      );
    });
github GetTerminus / ngx-tools / ngx-tools / utilities / src / http-retryer / http-retryer.spec.ts View on Github external
test(`should handle a delay with a specific retry date time`, () => {
      const waitTime = time(`${'-'.repeat(100)  }|`);
      const emissionTime = new Date(getTestScheduler().now() + waitTime);

      const retryErrorWithSpecificDelay = new HttpErrorResponse({
        status: 429,
        headers: new HttpHeaders({ 'Retry-After': emissionTime.toString() }),
      });

      getTestScheduler().maxFrames = 1500;

      (expect(
        errorAfter(3, retryErrorWithSpecificDelay, 1).pipe(
          httpRetryer({ scheduler: getTestScheduler() }),
        ),
      ) as any).toBeObservable(
        // Note the '- 2' account for the time it takes to get to the first error
        cold(`ab${  '-'.repeat(100 - 2)  }abcd`, {
github opfab / operatorfabric-core / ui / main / src / app / store / effects / translate.effects.spec.ts View on Github external
// there is no i18n file referenced in the store
        const cachedI18n$ = hot('-b', {b:new Map>()});
        storeMock.select.withArgs(selectI18nUpLoaded).and.returnValue(cachedI18n$);


        expect(underTest).toBeTruthy();



        // an UpdateTranslation is expected
        const expectedVersions=new Set(lightCards.map(card=>card.publisherVersion));
        const expectedThirdAndVersion=generateThirdWithVersion('testPublisher',expectedVersions);
        const expectedEmittedActions = hot('-c'
            , {
                c: new UpdateTranslation({versions: expectedThirdAndVersion})
            });
        expect(underTest.verifyTranslationNeeded).toBeObservable(expectedEmittedActions);
    });
github stefanoslig / angular-ngrx-nx-realworld-example-app / libs / auth / src / lib / +state / auth.effects.spec.ts View on Github external
it('should return a [ngrx-forms] SetErrors action if the register service throws', () => {
      const result = {
        error: {
          errors: { invalid: 'Invalid data' } as Errors,
        },
      };
      const registerAction = AuthActions.register();
      const setErrors = new SetErrors(result.error.errors);

      actions$ = hot('-a---', { a: registerAction });
      const response = cold('-#', {}, result);
      service.register = jest.fn(() => response);
      const expected = cold('--b', { b: setErrors });

      expect(effects.register$).toBeObservable(expected);
    });
  });
github SciCatProject / catanie / src / app / state-management / effects / jobs.effects.spec.ts View on Github external
it("should dispatch a showMessageAction", () => {
      const message = {
        type: MessageType.Success,
        content: "Job Created Successfully",
        duration: 5000
      };
      const action = fromActions.submitJobCompleteAction({ job });
      const outcome = showMessageAction({ message });

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

      const expected = cold("-b", { b: outcome });
      expect(effects.submitJobCompleteMessage$).toBeObservable(expected);
    });
  });
github burke-software / django-report-builder / js / src / app / effects / reports.spec.ts View on Github external
it("CheckExportStatus should dispatch another CheckExportStatus action if the download isn't ready", () => {
      actions = hot('a', {
        a: new Actions.CheckExportStatus({ reportId, taskId }),
      });
      const response = cold('-b', { b: { state: 'newp' } });
      const expected = cold(delay + 'c', {
        c: new Actions.CheckExportStatus({ reportId, taskId }),
      });

      service.checkStatus.and.returnValue(response);

      expect(effects.checkExportStatus$).toBeObservable(expected);
    });
github graycoreio / daffodil / apps / demo / src / app / product / pages / product-view / product-view.component.spec.ts View on Github external
it('should initialize product$', () => {
      facade.product$ = hot('ab', { a: null, b: mockProduct });
      component.ngOnInit();
      const expected = cold('ab', { a: null, b: mockProduct });
      expect(component.product$).toBeObservable(expected);
    });

jasmine-marbles

Marble testing helpers for RxJS and Jasmine

MIT
Latest version published 2 years ago

Package Health Score

59 / 100
Full package analysis