How to use the jasmine-marbles.getTestScheduler function in jasmine-marbles

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 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 SAP / cloud-commerce-spartacus-storefront / projects / storefrontlib / src / cms-components / product / product-interests / stock-notification / stock-notification.component.spec.ts View on Github external
it('should show loading when delete stock notification for login user with channel set', () => {
    productInterestService.getBackInStockSubscribed.and.returnValue(of(true));
    productInterestService.getDeleteBackInStockLoading.and.returnValue(
      cold('-a|', { a: true })
    );
    fixture.detectChanges();

    expect(
      el.query(By.css('[data-test]="btn-note-stopnotify"')).nativeElement
    ).toBeTruthy();
    const button = el.query(By.css('[data-test="btn-stopnotify"]'))
      .nativeElement;
    button.click();

    getTestScheduler().flush();
    fixture.detectChanges();

    expect(button.disabled).toEqual(true);
    expect(el.query(By.css('.cx-spinner'))).toBeTruthy();
  });
github SAP / cloud-commerce-spartacus-storefront / projects / storefrontlib / src / cms-components / myaccount / notification-preference / notification-preference.component.spec.ts View on Github external
it('should be able to disable a channel when update loading', () => {
    notificationPreferenceService.getPreferencesLoading.and.returnValue(
      of(false)
    );
    notificationPreferenceService.getUpdatePreferencesResultLoading.and.returnValue(
      cold('-a|', { a: true })
    );
    fixture.detectChanges();

    const cheboxies = el.queryAll(By.css('.form-check-input'));
    expect(cheboxies.length).toEqual(notificationPreference.length);
    const chx = cheboxies[0].nativeElement;
    chx.click();

    getTestScheduler().flush();
    fixture.detectChanges();

    expect(notificationPreferenceService.updatePreferences).toHaveBeenCalled();
    expect(chx.disabled).toEqual(true);
  });
});
github SAP / cloud-commerce-spartacus-storefront / projects / storefrontlib / src / cms-components / cart / save-for-later / save-for-later-item / save-for-later-item.component.spec.ts View on Github external
it('should call moveToCart()', () => {
    spyOn(
      component.saveForLaterItemComponent.moveToCart,
      'emit'
    ).and.callThrough();
    spyOnProperty(component, 'saveForLaterLoading').and.returnValue(
      cold('-b|', { a: true })
    );

    const moveAction = el.query(By.css('[data-test="move-btn"]')).nativeElement;
    moveAction.click();
    expect(
      component.saveForLaterItemComponent.moveToCart.emit
    ).toHaveBeenCalledWith(component.item);

    getTestScheduler().flush();
    fixture.detectChanges();
    expect(moveAction.disabled).toEqual(true);
  });
});
github sillsdev / web-languageforge / src / SIL.XForge.Scripture / ClientApp / src / app / connect-project / connect-project.component.spec.ts View on Github external
}
      ])
    );
    env.fixture.detectChanges();
    expect(env.component.state).toEqual('input');

    env.changeSelectValue(env.projectSelect, 'pt01');
    expect(env.sourceParatextIdControl.hasError('required')).toBe(true);
    expect(env.sourceParatextIdControl.disabled).toBe(false);

    env.clickElement(env.inputElement(env.checkingCheckbox));

    env.changeSelectValue(env.sourceProjectSelect, 'pt02');
    expect(env.component.connectProjectForm.valid).toBe(true);
    env.clickElement(env.submitButton);
    getTestScheduler().flush();
    tick();

    expect(env.component.state).toEqual('connecting');

    const project = new SFProject({
      projectName: 'Target',
      paratextId: 'pt01',
      inputSystem: {
        tag: 'en',
        languageName: 'English',
        abbreviation: 'en',
        isRightToLeft: false
      },
      checkingConfig: {
        enabled: true
      },
github DSpace / dspace-angular / src / app / core / integration / integration.service.spec.ts View on Github external
beforeEach(() => {
    responseCache = initMockResponseCacheService(true);
    requestService = getMockRequestService();
    scheduler = getTestScheduler();
    halService = new HALEndpointServiceStub(integrationEndpoint);
    findOptions = new IntegrationSearchOptions(uuid, name, metadata, query);
    service = initTestService();

  });
github DSpace / dspace-angular / src / app / core / data / request.service.spec.ts View on Github external
beforeEach(() => {
    scheduler = getTestScheduler();

    objectCache = getMockObjectCacheService();
    (objectCache.hasBySelfLink as any).and.returnValue(false);

    uuidService = getMockUUIDService();

    store = new Store(new BehaviorSubject({}), new ActionsSubject(), null);
    selectSpy = spyOnProperty(ngrx, 'select');
    selectSpy.and.callFake(() => {
      return () => {
        return () => cold('a', { a: undefined });
      };
    });

    service = new RequestService(
      objectCache,
github DSpace / dspace-angular / src / app / core / data / item-data.service.spec.ts View on Github external
beforeEach(() => {
      scheduler = getTestScheduler();
      service = initTestService();

    });
github DSpace / dspace-angular / src / app / core / submission / submission-rest.service.spec.ts View on Github external
beforeEach(() => {
    requestService = getMockRequestService();
    rdbService = getMockRemoteDataBuildService();
    scheduler = getTestScheduler();
    halService = new HALEndpointServiceStub(resourceEndpointURL);
    service = initTestService();

  });

jasmine-marbles

Marble testing helpers for RxJS and Jasmine

MIT
Latest version published 2 years ago

Package Health Score

59 / 100
Full package analysis