Skip to content

Commit

Permalink
test(sequenceEqual): round out tests for sequenceEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
benlesh committed Aug 16, 2016
1 parent 634f171 commit c239460
Showing 1 changed file with 103 additions and 1 deletion.
104 changes: 103 additions & 1 deletion spec/operators/sequenceEqual-spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//declare const {rxTestScheduler, time, hot, cold, asDiagram, expectObservable, expectSubscriptions, type};
declare const {rxTestScheduler, time, type};

const booleans = { T: true, F: false };

Expand All @@ -18,6 +18,108 @@ describe('Observable.prototype.sequenceEqual', () => {
expectSubscriptions(s2.subscriptions).toBe(s2subs);
});

it('should error with an errored source', () => {
const s1 = hot('--a--^--b---c---#');
const s2 = hot('--a--^--b---c-----|');
const expected = '-----------#';
const sub = '^ !';

const source = s1.sequenceEqual(s2);

expectObservable(source).toBe(expected, booleans);
expectSubscriptions(s1.subscriptions).toBe(sub);
expectSubscriptions(s2.subscriptions).toBe(sub);
});

it('should error with an errored compareTo', () => {
const s1 = hot('--a--^--b---c-----|');
const s2 = hot('--a--^--b---c---#');
const expected = '-----------#';
const sub = '^ !';

const source = s1.sequenceEqual(s2);

expectObservable(source).toBe(expected, booleans);
expectSubscriptions(s1.subscriptions).toBe(sub);
expectSubscriptions(s2.subscriptions).toBe(sub);
});

it('should error if the source is a throw', () => {
const s1 = cold('#'); // throw
const s2 = cold('---a--b--c--|');
const expected = '#'; // throw

const source = s1.sequenceEqual(s2);

expectObservable(source).toBe(expected);
});

it('should never return if source is a never', () => {
const s1 = cold('------------'); // never
const s2 = cold('--a--b--c--|');
const expected = '------------'; // never

const source = s1.sequenceEqual(s2);

expectObservable(source).toBe(expected);
});

it('should never return if compareTo is a never', () => {
const s1 = cold('--a--b--c--|');
const s2 = cold('------------'); // never
const expected = '------------'; // never

const source = s1.sequenceEqual(s2);

expectObservable(source).toBe(expected);
});

it('should return false if source is empty and compareTo is not', () => {
const s1 = cold('|'); // empty
const s2 = cold('------a------');
const expected = '------(F|)';
const subs = '^ !';

const source = s1.sequenceEqual(s2);

expectObservable(source).toBe(expected, booleans);
expectSubscriptions(s1.subscriptions).toBe(subs);
expectSubscriptions(s2.subscriptions).toBe(subs);
});

it('should return false if compareTo is empty and source is not', () => {
const s1 = cold('------a------');
const s2 = cold('|'); // empty
const expected = '------(F|)';
const subs = '^ !';

const source = s1.sequenceEqual(s2);

expectObservable(source).toBe(expected, booleans);
expectSubscriptions(s1.subscriptions).toBe(subs);
expectSubscriptions(s2.subscriptions).toBe(subs);
});

it('should return never if compareTo is empty and source is never', () => {
const s1 = cold('-');
const s2 = cold('|');
const expected = '-';

const source = s1.sequenceEqual(s2);

expectObservable(source).toBe(expected);
});

it('should return never if source is empty and compareTo is never', () => {
const s1 = cold('|');
const s2 = cold('-');
const expected = '-';

const source = s1.sequenceEqual(s2);

expectObservable(source).toBe(expected);
});

it('should error if the comparor errors', () => {
const s1 = hot('--a--^--b-----c------d--|');
const s1subs = '^ !';
Expand Down

0 comments on commit c239460

Please sign in to comment.