本文整理汇总了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();
});
});
示例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();
});
});
示例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();
});
});