forked from Reactive-Extensions/RxJS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathisempty.js
More file actions
52 lines (47 loc) · 1.71 KB
/
Copy pathisempty.js
File metadata and controls
52 lines (47 loc) · 1.71 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
QUnit.module('IsEmpty');
var TestScheduler = Rx.TestScheduler,
onNext = Rx.ReactiveTest.onNext,
onError = Rx.ReactiveTest.onError,
onCompleted = Rx.ReactiveTest.onCompleted,
subscribe = Rx.ReactiveTest.subscribe;
test('IsEmpty_Empty', function () {
var res, scheduler, xs;
scheduler = new TestScheduler();
xs = scheduler.createHotObservable(onNext(150, 1), onCompleted(250));
res = scheduler.startWithCreate(function () {
return xs.isEmpty();
}).messages;
res.assertEqual(onNext(250, true), onCompleted(250));
xs.subscriptions.assertEqual(subscribe(200, 250));
});
test('IsEmpty_Return', function () {
var res, scheduler, xs;
scheduler = new TestScheduler();
xs = scheduler.createHotObservable(onNext(150, 1), onNext(210, 2), onCompleted(250));
res = scheduler.startWithCreate(function () {
return xs.isEmpty();
}).messages;
res.assertEqual(onNext(210, false), onCompleted(210));
xs.subscriptions.assertEqual(subscribe(200, 210));
});
test('IsEmpty_Throw', function () {
var ex, res, scheduler, xs;
ex = 'ex';
scheduler = new TestScheduler();
xs = scheduler.createHotObservable(onNext(150, 1), onError(210, ex));
res = scheduler.startWithCreate(function () {
return xs.isEmpty();
}).messages;
res.assertEqual(onError(210, ex));
xs.subscriptions.assertEqual(subscribe(200, 210));
});
test('IsEmpty_Never', function () {
var res, scheduler, xs;
scheduler = new TestScheduler();
xs = scheduler.createHotObservable(onNext(150, 1));
res = scheduler.startWithCreate(function () {
return xs.isEmpty();
}).messages;
res.assertEqual();
xs.subscriptions.assertEqual(subscribe(200, 1000));
});