forked from Reactive-Extensions/RxJS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfor.js
More file actions
31 lines (28 loc) · 1.17 KB
/
Copy pathfor.js
File metadata and controls
31 lines (28 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
QUnit.module('For');
var Observable = Rx.Observable,
TestScheduler = Rx.TestScheduler,
onNext = Rx.ReactiveTest.onNext,
onError = Rx.ReactiveTest.onError,
onCompleted = Rx.ReactiveTest.onCompleted,
subscribe = Rx.ReactiveTest.subscribe;
test('For_Basic', function () {
var results, scheduler;
scheduler = new TestScheduler();
results = scheduler.startWithCreate(function () {
return Observable.forIn([1, 2, 3], function (x) {
return scheduler.createColdObservable(onNext(x * 100 + 10, x * 10 + 1), onNext(x * 100 + 20, x * 10 + 2), onNext(x * 100 + 30, x * 10 + 3), onCompleted(x * 100 + 40));
});
});
results.messages.assertEqual(onNext(310, 11), onNext(320, 12), onNext(330, 13), onNext(550, 21), onNext(560, 22), onNext(570, 23), onNext(890, 31), onNext(900, 32), onNext(910, 33), onCompleted(920));
});
test('For_Throws', function () {
var ex, results, scheduler;
ex = 'ex';
scheduler = new TestScheduler();
results = scheduler.startWithCreate(function () {
return Observable.forIn([1, 2, 3], function () {
throw ex;
});
});
results.messages.assertEqual(onError(200, ex));
});