Skip to content

Commit

Permalink
test(toArray): add basic type definition test
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Mar 10, 2016
1 parent 62d0946 commit fffc586
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion spec/helpers/test-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ global.hot = marbleHelpers.hot;
global.time = marbleHelpers.time;
global.expectObservable = marbleHelpers.expectObservable;
global.expectSubscriptions = marbleHelpers.expectSubscriptions;
global.type = type;

//amending type definition of jasmine which seems doesn't have this
export interface DoneSignature {
Expand Down Expand Up @@ -77,6 +78,11 @@ if (!global.asDiagram) {
global.asDiagram = asDiagram;
}

export function type(assertion: Function): void {
//intentionally does not execute to avoid unexpected side effect occurs by subscription,
//or infinite source. Suffecient to check build time only.
}

export function lowerCaseO<T>(...args): Rx.Observable<T> {
const values = [].slice.apply(arguments);

Expand Down Expand Up @@ -154,4 +160,4 @@ global.__root__ = root;

afterEach(function () {
global.rxTestScheduler = null;
});
});
10 changes: 9 additions & 1 deletion spec/operators/toArray-spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Rx from '../../dist/cjs/Rx';
declare const {hot, cold, asDiagram, expectObservable, expectSubscriptions};
declare const {hot, cold, asDiagram, expectObservable, expectSubscriptions, type};

const Observable = Rx.Observable;

Expand Down Expand Up @@ -101,4 +101,12 @@ describe('Observable.prototype.toArray', () => {
expectObservable(e1.toArray()).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
});

type(() => {
const typeValue = {
val: 3
};

Observable.of(typeValue).toArray().subscribe(x => { x[0].val.toString(); });
});
});

0 comments on commit fffc586

Please sign in to comment.