Skip to content

Commit 2c1a794

Browse files
committed
chore(test): update type definitions
1 parent 98e183d commit 2c1a794

File tree

5 files changed

+55
-46
lines changed

5 files changed

+55
-46
lines changed

spec/observables/dom/ajax-spec.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {MockXMLHttpRequest} from '../../helpers/ajax-helper';
44
import {it} from '../../helpers/test-helper';
55

66
declare const global: any;
7-
//declare const XMLHttpRequest: MockXMLHttpRequest;
87

98
describe('Observable.ajax', () => {
109
let gXHR: XMLHttpRequest;
@@ -25,16 +24,17 @@ describe('Observable.ajax', () => {
2524
});
2625

2726
it('should set headers', () => {
28-
const obj = {
27+
const obj: Rx.AjaxRequest = {
2928
url: '/talk-to-me-goose',
3029
headers: {
3130
'Content-Type': 'kenny/loggins',
3231
'Fly-Into-The': 'Dangah Zone!',
3332
'Take-A-Ride-Into-The': 'Danger ZoooOoone!'
34-
}
33+
},
34+
method: ''
3535
};
3636

37-
(<any>Rx.Observable.ajax)(obj).subscribe();
37+
Rx.Observable.ajax(obj).subscribe();
3838

3939
const request = MockXMLHttpRequest.mostRecent;
4040

@@ -85,10 +85,11 @@ describe('Observable.ajax', () => {
8585
responseType: 'text',
8686
resultSelector: (res: any) => {
8787
throw new Error('ha! ha! fooled you!');
88-
}
88+
},
89+
method: ''
8990
};
9091

91-
(<any>Rx.Observable.ajax)(obj)
92+
Rx.Observable.ajax(obj)
9293
.subscribe((x: any) => {
9394
throw 'should not next';
9495
}, (err: any) => {
@@ -137,9 +138,10 @@ describe('Observable.ajax', () => {
137138
const obj = {
138139
url: '/flibbertyJibbet',
139140
responseType: 'text',
141+
method: ''
140142
};
141143

142-
(<any>Rx.Observable.ajax)(obj)
144+
Rx.Observable.ajax(obj)
143145
.subscribe((x: any) => {
144146
result = x;
145147
}, null, () => {
@@ -166,10 +168,11 @@ describe('Observable.ajax', () => {
166168
normalizeError: (e: any, xhr: any, type: any) => {
167169
return xhr.response || xhr.responseText;
168170
},
169-
responseType: 'text'
171+
responseType: 'text',
172+
method: ''
170173
};
171174

172-
(<any>Rx.Observable.ajax)(obj)
175+
Rx.Observable.ajax(obj)
173176
.subscribe((x: any) => {
174177
throw 'should not next';
175178
}, (err: any) => {
@@ -198,10 +201,11 @@ describe('Observable.ajax', () => {
198201
normalizeError: (e: any, xhr: any, type: any) => {
199202
return xhr.response || xhr.responseText;
200203
},
201-
responseType: 'text'
204+
responseType: 'text',
205+
method: ''
202206
};
203207

204-
(<any>Rx.Observable.ajax)(obj).subscribe((x: any) => {
208+
Rx.Observable.ajax(obj).subscribe((x: any) => {
205209
throw 'should not next';
206210
}, (err: any) => {
207211
error = err;
@@ -224,8 +228,8 @@ describe('Observable.ajax', () => {
224228

225229
it('should succeed no settings', () => {
226230
const expected = JSON.stringify({ foo: 'bar' });
227-
//Type definition need to be updated
228-
(<any>Rx.Observable.ajax)('/flibbertyJibbet')
231+
232+
Rx.Observable.ajax('/flibbertyJibbet')
229233
.subscribe((x: any) => {
230234
expect(x.status).toBe(200);
231235
expect(x.xhr.method).toBe('GET');
@@ -245,7 +249,7 @@ describe('Observable.ajax', () => {
245249
it('should fail no settings', () => {
246250
const expected = JSON.stringify({ foo: 'bar' });
247251

248-
(<any>Rx.Observable.ajax)('/flibbertyJibbet')
252+
Rx.Observable.ajax('/flibbertyJibbet')
249253
.subscribe(() => {
250254
throw 'should not have been called';
251255
}, (x: any) => {

spec/operators/distinctUntilChanged-spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ describe('Observable.prototype.distinctUntilChanged()', () => {
195195
const comparator = (x: number, y: number) => y % 2 === 1;
196196
const keySelector = (x: number) => x % 2;
197197

198-
expectObservable((<any>e1).distinctUntilChanged(comparator, keySelector)).toBe(expected, {a: 1, b: 2, d: 4, f: 6});
198+
expectObservable(e1.distinctUntilChanged(comparator, keySelector)).toBe(expected, {a: 1, b: 2, d: 4, f: 6});
199199
expectSubscriptions(e1.subscriptions).toBe(e1subs);
200200
});
201201

@@ -210,7 +210,7 @@ describe('Observable.prototype.distinctUntilChanged()', () => {
210210
return x;
211211
};
212212

213-
expectObservable((<any>e1).distinctUntilChanged(null, keySelector)).toBe(expected);
213+
expectObservable(e1.distinctUntilChanged(null, keySelector)).toBe(expected);
214214
expectSubscriptions(e1.subscriptions).toBe(e1subs);
215215
});
216216
});

spec/operators/do-spec.ts

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as Rx from '../../dist/cjs/Rx';
22
import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marble-testing';
3-
import {it, asDiagram} from '../helpers/test-helper';
3+
import {it, asDiagram, DoneSignature} from '../helpers/test-helper';
44

55
const Observable = Rx.Observable;
66
const Subject = Rx.Subject;
@@ -11,7 +11,9 @@ describe('Observable.prototype.do()', () => {
1111
const e1subs = '^ !';
1212
const expected = '--1--2--3--|';
1313

14-
const result = (<any>e1).do();
14+
const result = e1.do(() => {
15+
//noop
16+
});
1517
expectObservable(result).toBe(expected);
1618
expectSubscriptions(e1.subscriptions).toBe(e1subs);
1719
});
@@ -38,52 +40,46 @@ describe('Observable.prototype.do()', () => {
3840
expect(err).toBe('bad');
3941
});
4042

41-
it('should handle everything with an observer', () => {
43+
it('should handle everything with an observer', (done: DoneSignature) => {
4244
const expected = [1, 2, 3];
4345
const results = [];
44-
let completeCalled = false;
46+
4547
Observable.of(1, 2, 3)
46-
.do(<any>{
48+
.do(<Rx.Observer<number>>{
4749
next: (x: number) => {
4850
results.push(x);
4951
},
5052
error: (err: any) => {
51-
throw 'should not be called';
53+
done.fail('should not be called');
5254
},
5355
complete: () => {
54-
completeCalled = true;
56+
expect(results).toEqual(expected);
57+
done();
5558
}
56-
})
57-
.subscribe();
58-
59-
expect(completeCalled).toBe(true);
60-
expect(results).toEqual(expected);
59+
}).subscribe();
6160
});
6261

63-
it('should handle everything with a Subject', () => {
62+
it('should handle everything with a Subject', (done: DoneSignature) => {
6463
const expected = [1, 2, 3];
6564
const results = [];
66-
let completeCalled = false;
6765
const subject = new Subject();
6866

6967
subject.subscribe({
7068
next: (x: any) => {
7169
results.push(x);
7270
},
7371
error: (err: any) => {
74-
throw 'should not be called';
72+
done.fail('should not be called');
7573
},
7674
complete: () => {
77-
completeCalled = true;
75+
expect(results).toEqual(expected);
76+
done();
7877
}
7978
});
8079

8180
Observable.of(1, 2, 3)
82-
.do(<any>subject)
81+
.do(<Rx.Observer<number>>subject)
8382
.subscribe();
84-
85-
expect(completeCalled).toBe(true);
86-
expect(results).toEqual(expected);
8783
});
8884

8985
it('should handle an error with a callback', () => {
@@ -172,7 +168,9 @@ describe('Observable.prototype.do()', () => {
172168
const e1subs = '^ ! ';
173169
const expected = '--1--2-- ';
174170

175-
const result = (<any>e1).do();
171+
const result = e1.do(() => {
172+
//noop
173+
});
176174
expectObservable(result, unsub).toBe(expected);
177175
expectSubscriptions(e1.subscriptions).toBe(e1subs);
178176
});
@@ -183,9 +181,11 @@ describe('Observable.prototype.do()', () => {
183181
const expected = '--1--2-- ';
184182
const unsub = ' ! ';
185183

186-
const result = (<any>e1)
184+
const result = e1
187185
.mergeMap((x: any) => Observable.of(x))
188-
.do()
186+
.do(() => {
187+
//noop
188+
})
189189
.mergeMap((x: any) => Observable.of(x));
190190

191191
expectObservable(result, unsub).toBe(expected);
@@ -197,7 +197,9 @@ describe('Observable.prototype.do()', () => {
197197
const e1subs = '^ !';
198198
const expected = '--1--2--3--|';
199199

200-
const result = (<any>e1).do();
200+
const result = e1.do(() => {
201+
//noop
202+
});
201203
expectObservable(result).toBe(expected);
202204
expectSubscriptions(e1.subscriptions).toBe(e1subs);
203205
});
@@ -207,7 +209,9 @@ describe('Observable.prototype.do()', () => {
207209
const e1subs = '^ !';
208210
const expected = '--1--2--3--#';
209211

210-
const result = (<any>e1).do();
212+
const result = e1.do(() => {
213+
//noop
214+
});
211215
expectObservable(result).toBe(expected);
212216
expectSubscriptions(e1.subscriptions).toBe(e1subs);
213217
});

spec/operators/startWith-spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('Observable.prototype.startWith()', () => {
7676
const e1subs = '^ !';
7777
const expected = '(yz)-a--|';
7878

79-
expectObservable((<any>e1).startWith('y', 'z')).toBe(expected);
79+
expectObservable(e1.startWith('y', 'z')).toBe(expected);
8080
expectSubscriptions(e1.subscriptions).toBe(e1subs);
8181
});
8282

@@ -105,7 +105,7 @@ describe('Observable.prototype.startWith()', () => {
105105
const expected = 's--a--b---';
106106
const values = { s: 's', a: 'a', b: 'b' };
107107

108-
const result = (<any>e1).startWith('s', rxTestScheduler);
108+
const result = e1.startWith('s', rxTestScheduler);
109109

110110
expectObservable(result, unsub).toBe(expected, values);
111111
expectSubscriptions(e1.subscriptions).toBe(e1subs);
@@ -118,7 +118,7 @@ describe('Observable.prototype.startWith()', () => {
118118
const unsub = ' ! ';
119119
const values = { s: 's', a: 'a', b: 'b' };
120120

121-
const result = (<any>e1)
121+
const result = e1
122122
.mergeMap((x: string) => Observable.of(x))
123123
.startWith('s', rxTestScheduler)
124124
.mergeMap((x: string) => Observable.of(x));
@@ -141,7 +141,7 @@ describe('Observable.prototype.startWith()', () => {
141141
const e1subs = '^ !';
142142
const expected = 'x-a--|';
143143

144-
expectObservable((<any>e1).startWith(defaultStartValue, rxTestScheduler)).toBe(expected);
144+
expectObservable(e1.startWith(defaultStartValue, rxTestScheduler)).toBe(expected);
145145
expectSubscriptions(e1.subscriptions).toBe(e1subs);
146146
});
147147

@@ -150,7 +150,7 @@ describe('Observable.prototype.startWith()', () => {
150150
const e1subs = '^ !';
151151
const expected = '(yz)-a--|';
152152

153-
expectObservable((<any>e1).startWith('y', 'z', rxTestScheduler)).toBe(expected);
153+
expectObservable(e1.startWith('y', 'z', rxTestScheduler)).toBe(expected);
154154
expectSubscriptions(e1.subscriptions).toBe(e1subs);
155155
});
156156
});

src/Rx.DOM.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ var Symbol = {
146146
/* tslint:enable:no-var-keyword */
147147

148148
export {
149+
AjaxRequest,
149150
AjaxResponse,
150151
AjaxError,
151152
AjaxTimeoutError,

0 commit comments

Comments
 (0)