当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Rx.TestScheduler类代码示例

本文整理汇总了TypeScript中rxjs/Rx.TestScheduler的典型用法代码示例。如果您正苦于以下问题:TypeScript TestScheduler类的具体用法?TypeScript TestScheduler怎么用?TypeScript TestScheduler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TestScheduler类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: describe

describe('Observable', () => {
  let ts: TestScheduler;
  let hot: typeof TestScheduler.prototype.createHotObservable;
  let cold: typeof TestScheduler.prototype.createColdObservable;


  beforeEach(() => {
    ts = new TestScheduler(assert.deepEqual);
    hot = ts.createHotObservable.bind(ts);
    cold = ts.createColdObservable.bind(ts);
  });


  it('should return correct observable', () => {
    const source = cold<number>('-a-b-c', { a: 1, b: 2, c: 3 });
    const expected = '---b-c';
    const expectedValues = { a: 10, b: 20, c: 30 };

    ts.expectObservable(maptest(source)).toBe(expected, expectedValues);
    ts.flush();
  });


  it('should pass', () => {
    assert(1 + 1 === 2);
  });


  iit('counterObservable', () => {    
    const source = hot<number>('^--a-b-c', { a: 1, b: 1, c: 2 });
    const marbles = '---a-b-c';
    const values = { a: 1, b: 2, c: 5 };
    ts.expectObservable(counterObservable(source)).toBe(marbles, values);
    ts.flush();
  });

});
开发者ID:ovrmrw,项目名称:angular2-testing-sample,代码行数:37,代码来源:page1.rxjs.spec.ts

示例2: describe

describe('TEST: RxJS Marble Test basics', () => {
  /* >>> boilerplate */
  let ts: TestScheduler;
  let hot: typeof TestScheduler.prototype.createHotObservable;
  let cold: typeof TestScheduler.prototype.createColdObservable;

  beforeEach(() => {
    ts = new TestScheduler(assert.deepEqual);
    hot = ts.createHotObservable.bind(ts);
    cold = ts.createColdObservable.bind(ts);
  });
  /* <<< boilerplate */


  it('should return correct observable', () => {
    const source$ = cold<number>('-a-b-c', { a: 1, b: 2, c: 3 });
    const marbles = '---B-C';
    const values = { A: 10, B: 20, C: 30 };
    const test$ = mapFilterTest(source$);
    ts.expectObservable(test$).toBe(marbles, values);
    ts.flush();
  });

});
开发者ID:ovrmrw,项目名称:ovrmrw-ng2-env-20160725,代码行数:24,代码来源:sample1.ts

示例3: describe

describe('TEST: Store', () => {
  /* >>> boilerplate */
  let ts: TestScheduler;
  let hot: typeof TestScheduler.prototype.createHotObservable;
  let cold: typeof TestScheduler.prototype.createColdObservable;

  beforeEach(() => {
    ts = new TestScheduler(assert.deepEqual);
    hot = ts.createHotObservable.bind(ts);
    cold = ts.createColdObservable.bind(ts);
  });
  /* <<< boilerplate */


  it('"incrementObservable" should return correct observable', () => {
    const source$ = hot<number>('---^a-b-c---d--e', { a: 0, b: 1, c: 1, d: 2, e: -1 });
    const marbles = '-A-B-C---D--E';
    const values = { A: 0, B: 1, C: 2, D: 4, E: 3 };
    const test$ = incrementObservable(source$, true);
    ts.expectObservable(test$).toBe(marbles, values);
    ts.flush();
  });

});
开发者ID:ovrmrw,项目名称:ionic2-testing-sample,代码行数:24,代码来源:store.spec.ts


注:本文中的rxjs/Rx.TestScheduler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。