(and)count as frame
describe('`(` and `)`', () => {
let testScheduler: TestScheduler;
beforeEach(() => {
testScheduler = new TestScheduler(observableMatcher);
});
describe.only('`(` and `)`', () => {
let testScheduler: TestScheduler;
beforeEach(() => {
testScheduler = new TestScheduler(observableMatcher);
});
it('should take one frame for `(` and one frame for `)`', () => {
testScheduler.run(({cold, hot, expectObservable}) => {
const a = cold('---------------|');
const a1 = '-()------------|';
const b = cold('----1----------|');
const b1 = '-()-(1)--------|';
const b2 = '-()-(1)--()----|';
const c = cold('----1----(23)--|');
const c1 = '-()-(1)()(23)--|';
const c2 = '-()-(1)()(23)--|';
const c3 = '-()-(1)()(23)()|';
expectObservable(a).toBe(a1);
expectObservable(b).toBe(b1);
expectObservable(b).toBe(b2);
expectObservable(c).toBe(c1);
expectObservable(c).toBe(c2);
expectObservable(c).toBe(c3);
});
});
});^only exists in hot observables
describe.only('`^`', () => {
let testScheduler: TestScheduler;
beforeEach(() => {
testScheduler = new TestScheduler(observableMatcher);
});
it('should take one frame', () => {
const a = cold('-1---|');
const a1 = '-1---|';
const aSubs = [
'^----!'
];
const ar = a.pipe(tap());
expectObservable(ar).toBe(a1);
expectSubscriptions(a.subscriptions).toBe(aSubs);
});
it('should exist only on hot observables and outputs ans subscriptions', () => {
testScheduler.run(({hot, expectObservable}) => {
const a = hot('^1----------|');
const a1 = '^1----------|';
const aSubs = '^-----------!';
const ar = a.pipe(tap());
expectObservable(ar).toBe(a1);
expectSubscriptions(a.subscriptions).toBe(aSubs);
});
});
});is ignored in cold and hot observables due to time progression syntax, but considered as frame in subscriptions
The zero index exists only in hot observables and can be specified by using ^.
If not specified it exists implizitly at the beginning of an hot observable.
hot('----|') === hot(' ----|') === hot('^---|') === hot(' ^---|')
hot('-^---|') === hot('-^---|') :D// Old style ==================
import { hot, cold, expectObservable, expectSubscriptions } from '../helpers/marble-testing';
const s1 = hot('-^-x------------------|');
const s1Subs = '^ !';
const n1 = cold(' ------------------------|');
const n1Subs = [' ^ !'];
const exp = '--x------------------|';
// New style ==================
import {TestScheduler} from 'rxjs/internal/testing/TestScheduler';
const testScheduler = new TestScheduler(observableMatcher);
testScheduler.run(({cold, hot, expectObservable, expectSubscriptions}) => {
const s1 = hot('-^-x------------------| ');
const s1Subs = '^--------------------! ';
const n1 = cold('------------------------|');
const n1Subs = ['--^------------------! '];
const exp = '--x------------------| ';
// New style proper 0 index alignment ==================
import {TestScheduler} from 'rxjs/internal/testing/TestScheduler';
const testScheduler = new TestScheduler(observableMatcher);
testScheduler.run(({cold, hot, expectObservable, expectSubscriptions}) => {
const s1 = hot('-^-x------------------| ');
const s1Subs = ' ^--------------------! ';
const n1 = cold(' ------------------------|');
const n1Subs = [' --^------------------! '];
const exp = ' --x------------------| ';
})