Skip to content

Commit

Permalink
chore(test): fix observable test types (#3732)
Browse files Browse the repository at this point in the history
* chore(test): check dom/* observables

* chore(test): fix ajax types

* chore(test): check b*, c*, d* observables

* chore(test): fix defer types

* chore(test): check e*, f* observables

* chore(test): fix forkJoin types

* chore(test): fix fromEvent types

* chore(test): check g* observables

* chore(test): fix generate types

* chore(test): check i* - z* observables

* chore(test): fix zip types
  • Loading branch information
cartant authored and benlesh committed May 25, 2018
1 parent 0bda9cd commit d7bfc9d
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 39 deletions.
8 changes: 4 additions & 4 deletions spec/observables/defer-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,26 @@ describe('defer', () => {
it('should accept factory returns promise resolves', (done: MochaDone) => {
const expected = 42;
const e1 = defer(() => {
return new Promise((resolve: any) => { resolve(expected); });
return new Promise<number>((resolve: any) => { resolve(expected); });
});

e1.subscribe((x: number) => {
expect(x).to.equal(expected);
done();
}, x => {
}, (x: any) => {
done(new Error('should not be called'));
});
});

it('should accept factory returns promise rejects', (done: MochaDone) => {
const expected = 42;
const e1 = defer(() => {
return new Promise((resolve: any, reject: any) => { reject(expected); });
return new Promise<number>((resolve: any, reject: any) => { reject(expected); });
});

e1.subscribe((x: number) => {
done(new Error('should not be called'));
}, x => {
}, (x: any) => {
expect(x).to.equal(expected);
done();
}, () => {
Expand Down
12 changes: 6 additions & 6 deletions spec/observables/dom/ajax-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ describe('Observable.ajax', () => {

it('should succeed on 200', () => {
const expected = { foo: 'bar' };
let result;
let result: Rx.AjaxResponse;
let complete = false;
const obj = {
url: '/flibbertyJibbet',
Expand Down Expand Up @@ -281,7 +281,7 @@ describe('Observable.ajax', () => {
});

it('should succeed on 300', () => {
let result;
let result: Rx.AjaxResponse;
let complete = false;
const obj = {
url: '/flibbertyJibbet',
Expand Down Expand Up @@ -600,7 +600,7 @@ describe('Observable.ajax', () => {
});

it('should succeed on 204 No Content', () => {
const expected = null;
const expected: null = null;
let result;
let complete = false;

Expand Down Expand Up @@ -722,7 +722,7 @@ describe('Observable.ajax', () => {
});

it('should succeed on 204 No Content', () => {
const expected = null;
const expected: null = null;
let result: Rx.AjaxResponse;
let complete = false;

Expand Down Expand Up @@ -754,7 +754,7 @@ describe('Observable.ajax', () => {
});

it('should succeed in IE on 204 No Content', () => {
const expected = null;
const expected: null = null;
let result: Rx.AjaxResponse;
let complete = false;

Expand Down Expand Up @@ -953,7 +953,7 @@ describe('Observable.ajax', () => {
const request = MockXMLHttpRequest.mostRecent;

expect(() => {
request.upload.onprogress((<any>'onprogress'));
(request.upload as any).onprogress((<any>'onprogress'));
}).not.throw();

delete root.XMLHttpRequest.prototype.onprogress;
Expand Down
4 changes: 2 additions & 2 deletions spec/observables/forkJoin-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ describe('forkJoin', () => {
let b: Promise<string>;
let c: Promise<boolean>;
let o1: Observable<[number, string, boolean]> = forkJoin(a, b, c);
let o2: Observable<boolean> = forkJoin(a, b, c, (aa, bb, cc) => !!aa && !!bb && cc);
let o2: Observable<boolean> = forkJoin(a, b, c, (aa: number, bb: string, cc: boolean) => !!aa && !!bb && cc);
/* tslint:enable:no-unused-variable */
});

Expand All @@ -304,7 +304,7 @@ describe('forkJoin', () => {
let b: Observable<string>;
let c: Observable<boolean>;
let o1: Observable<[number, string, boolean]> = forkJoin(a, b, c);
let o2: Observable<boolean> = forkJoin(a, b, c, (aa, bb, cc) => !!aa && !!bb && cc);
let o2: Observable<boolean> = forkJoin(a, b, c, (aa: number, bb: string, cc: boolean) => !!aa && !!bb && cc);
/* tslint:enable:no-unused-variable */
});

Expand Down
6 changes: 4 additions & 2 deletions spec/observables/fromEvent-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,15 @@ describe('fromEvent', () => {
let offHandler;

const obj = {
addListener: (a: string, b: Function) => {
addListener(a: string | symbol, b: (...args: any[]) => void) {
onEventName = a;
onHandler = b;
return this;
},
removeListener: (a: string, b: Function) => {
removeListener(a: string | symbol, b: (...args: any[]) => void) {
offEventName = a;
offHandler = b;
return this;
}
};

Expand Down
4 changes: 2 additions & 2 deletions spec/observables/generate-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('generate', () => {
const source = generate({
initialState: 1,
iterate: x => x + 1,
resultSelector: x => x.toString()
resultSelector: (x: number) => x.toString()
}).take(5);
const expected = '(12345|)';

Expand All @@ -73,7 +73,7 @@ describe('generate', () => {
initialState: 1,
condition: x => x < 4,
iterate: x => x + 1,
resultSelector: x => x,
resultSelector: (x: number) => x,
scheduler: rxTestScheduler
});
const expected = '(123|)';
Expand Down
10 changes: 5 additions & 5 deletions spec/observables/zip-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('Observable.zip', () => {
let nextCalled = 0;
const myIterator = <any>{
count: 0,
next: () => {
next() {
nextCalled++;
return { value: this.count++, done: false };
}
Expand All @@ -127,7 +127,7 @@ describe('Observable.zip', () => {
it('should work with never observable and empty iterable', () => {
const a = cold( '-');
const asubs = '^';
const b = [];
const b: number[] = [];
const expected = '-';

expectObservable(Observable.zip(a, b)).toBe(expected);
Expand All @@ -137,7 +137,7 @@ describe('Observable.zip', () => {
it('should work with empty observable and empty iterable', () => {
const a = cold('|');
const asubs = '(^!)';
const b = [];
const b: number[] = [];
const expected = '|';

expectObservable(Observable.zip(a, b)).toBe(expected);
Expand All @@ -157,7 +157,7 @@ describe('Observable.zip', () => {
it('should work with non-empty observable and empty iterable', () => {
const a = hot('---^----a--|');
const asubs = '^ !';
const b = [];
const b: number[] = [];
const expected = '--------|';

expectObservable(Observable.zip(a, b)).toBe(expected);
Expand Down Expand Up @@ -187,7 +187,7 @@ describe('Observable.zip', () => {
it('should work with non-empty observable and empty iterable', () => {
const a = hot('---^----#');
const asubs = '^ !';
const b = [];
const b: number[] = [];
const expected = '-----#';

expectObservable(Observable.zip(a, b)).toBe(expected);
Expand Down
36 changes: 18 additions & 18 deletions spec/tsconfig.check.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
"./ajax/**/*.ts",
"./helpers/**/*.ts",
"./migration/**/*.ts",
/*"./observables/dom/*.ts",*/
/*"./observables/b*.ts",*/
/*"./observables/c*.ts",*/
/*"./observables/d*.ts",*/
/*"./observables/e*.ts",*/
/*"./observables/f*.ts",*/
/*"./observables/g*.ts",*/
/*"./observables/i*.ts",*/
/*"./observables/I*.ts",*/
/*"./observables/m*.ts",*/
/*"./observables/n*.ts",*/
/*"./observables/o*.ts",*/
/*"./observables/p*.ts",*/
/*"./observables/r*.ts",*/
/*"./observables/S*.ts",*/
/*"./observables/t*.ts",*/
/*"./observables/u*.ts",*/
/*"./observables/z*.ts",*/
"./observables/dom/*.ts",
"./observables/b*.ts",
"./observables/c*.ts",
"./observables/d*.ts",
"./observables/e*.ts",
"./observables/f*.ts",
"./observables/g*.ts",
"./observables/i*.ts",
"./observables/I*.ts",
"./observables/m*.ts",
"./observables/n*.ts",
"./observables/o*.ts",
"./observables/p*.ts",
"./observables/r*.ts",
"./observables/S*.ts",
"./observables/t*.ts",
"./observables/u*.ts",
"./observables/z*.ts",
"./operators/a*.ts",
"./operators/b*.ts",
"./operators/c*.ts",
Expand Down

0 comments on commit d7bfc9d

Please sign in to comment.