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