This repository has been archived by the owner on Apr 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
jortsort.js
105 lines (83 loc) · 2.21 KB
/
jortsort.js
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
(function () {
/* jshint undef: true, unused: true */
/* globals QUnit, test, Rx */
QUnit.module('jorSort');
var TestScheduler = Rx.TestScheduler,
onNext = Rx.ReactiveTest.onNext,
onError = Rx.ReactiveTest.onError,
onCompleted = Rx.ReactiveTest.onCompleted;
test('jortSort never', function () {
var scheduler = new TestScheduler();
var xs = scheduler.createHotObservable(
onNext(180, 1)
);
var results = scheduler.startWithCreate(function () {
return xs.jortSort();
});
results.messages.assertEqual();
});
test('jortSort empty', function () {
var scheduler = new TestScheduler();
var xs = scheduler.createHotObservable(
onNext(180, 1),
onCompleted(250)
);
var results = scheduler.startWithCreate(function () {
return xs.jortSort();
});
results.messages.assertEqual(
onNext(250, true),
onCompleted(250)
);
});
test('jortSort error', function () {
var scheduler = new TestScheduler();
var error = new Error();
var xs = scheduler.createHotObservable(
onNext(180, 1),
onError(250, error)
);
var results = scheduler.startWithCreate(function () {
return xs.jortSort();
});
results.messages.assertEqual(
onError(250, error)
);
});
test('jortSort returns true', function () {
var scheduler = new TestScheduler();
var xs = scheduler.createHotObservable(
onNext(180, 1),
onNext(210, 2),
onNext(220, 3),
onNext(230, 4),
onNext(240, 5),
onCompleted(250)
);
var results = scheduler.startWithCreate(function () {
return xs.jortSort();
});
results.messages.assertEqual(
onNext(250, true),
onCompleted(250)
);
});
test('jortSort returns false', function () {
var scheduler = new TestScheduler();
var xs = scheduler.createHotObservable(
onNext(180, 1),
onNext(210, 5),
onNext(220, 3),
onNext(230, 2),
onNext(240, 4),
onCompleted(250)
);
var results = scheduler.startWithCreate(function () {
return xs.jortSort();
});
results.messages.assertEqual(
onNext(250, false),
onCompleted(250)
);
});
}());