當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript TestScheduler.schedule方法代碼示例

本文整理匯總了TypeScript中rxjs/testing.TestScheduler.schedule方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript TestScheduler.schedule方法的具體用法?TypeScript TestScheduler.schedule怎麽用?TypeScript TestScheduler.schedule使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rxjs/testing.TestScheduler的用法示例。


在下文中一共展示了TestScheduler.schedule方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

  it('should return compare hot and cold observables', () => {
    const s1 = hot('---a--^---b---c---d---e---f---g---h---i---j---|');
    const s2 = cold(     '----b---c-|');
    const expected1 =    '------------(F|)';
    const subs1 =        '^           !';
    const delay =        '-------------------|';
    const s3 = cold(                        '-f---g---h---i---j---|');
    const expected2 =    '                   ---------------------(T|)';
    const subs2 =        '                   ^                    !';

    const test1 = s1.pipe(sequenceEqual(s2));
    const test2 = s1.pipe(sequenceEqual(s3));

    expectObservable(test1).toBe(expected1, booleans);
    rxTestScheduler.schedule(() => expectObservable(test2).toBe(expected2, booleans), time(delay));
    expectSubscriptions(s2.subscriptions).toBe(subs1);
    expectSubscriptions(s3.subscriptions).toBe(subs2);
  });
開發者ID:MykhailoIskiv,項目名稱:rxjs,代碼行數:18,代碼來源:sequenceEqual-spec.ts

示例2: it

    it('should be retryable using a ReplaySubject', () => {
      function subjectFactory() { return new ReplaySubject(1); }
      const source =     cold('-1-2-3----4-#                        ');
      const sourceSubs =     ['^           !                        ',
                              '            ^           !            ',
                              '                        ^           !'];
      const multicasted = source.pipe(
        multicast(subjectFactory),
        refCount()
      );
      const expected1 =       '-1-2-3----4--1-2-3----4--1-2-3----4-#';
      const subscribe2 = time('----|                                ');
      const expected2 =       '    23----4--1-2-3----4--1-2-3----4-#';

      expectObservable(multicasted.pipe(retry(2))).toBe(expected1);

      rxTestScheduler.schedule(() =>
        expectObservable(multicasted.pipe(retry(2))).toBe(expected2), subscribe2);

      expectSubscriptions(source.subscriptions).toBe(sourceSubs);
    });
開發者ID:DallanQ,項目名稱:rxjs,代碼行數:21,代碼來源:multicast-spec.ts

示例3: it

  it('should dispose window Subjects if the outer is unsubscribed early', () => {
    const source = hot('--a--b--c--d--e--f--g--h--|');
    const open =  cold('o-------------------------|');
    const sourceSubs = '^        !                 ';
    const expected =   'x---------                 ';
    const x = cold(    '--a--b--c-                 ');
    const unsub =      '         !                 ';
    const late =  time('---------------|           ');
    const values = { x };

    let window: Observable<string>;
    const result = source.pipe(
      windowToggle(open, () => NEVER),
      tap(w => { window = w; }),
    );

    expectObservable(result, unsub).toBe(expected, values);
    expectSubscriptions(source.subscriptions).toBe(sourceSubs);
    rxTestScheduler.schedule(() => {
      expect(() => {
        window.subscribe();
      }).to.throw(ObjectUnsubscribedError);
    }, late);
  });
開發者ID:DallanQ,項目名稱:rxjs,代碼行數:24,代碼來源:windowToggle-spec.ts


注:本文中的rxjs/testing.TestScheduler.schedule方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。