jasmine-core 1.3.1 → 2.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/jasmine-core.rb +14 -1
- data/lib/jasmine-core/boot.js +131 -0
- data/lib/jasmine-core/boot/boot.js +109 -0
- data/lib/jasmine-core/example/spec/PlayerSpec.js +2 -2
- data/lib/jasmine-core/example/spec/SpecHelper.js +14 -8
- data/lib/jasmine-core/jasmine-html.js +289 -616
- data/lib/jasmine-core/jasmine.css +52 -80
- data/lib/jasmine-core/jasmine.js +1972 -2211
- data/lib/jasmine-core/spec/console/ConsoleReporterSpec.js +161 -386
- data/lib/jasmine-core/spec/core/AnySpec.js +45 -0
- data/lib/jasmine-core/spec/core/CallTrackerSpec.js +105 -0
- data/lib/jasmine-core/spec/core/ClockSpec.js +314 -0
- data/lib/jasmine-core/spec/core/CustomMatchersSpec.js +96 -97
- data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +179 -0
- data/lib/jasmine-core/spec/core/EnvSpec.js +454 -102
- data/lib/jasmine-core/spec/core/ExceptionFormatterSpec.js +56 -0
- data/lib/jasmine-core/spec/core/ExceptionsSpec.js +15 -126
- data/lib/jasmine-core/spec/core/ExpectationResultSpec.js +61 -0
- data/lib/jasmine-core/spec/core/ExpectationSpec.js +320 -0
- data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +150 -38
- data/lib/jasmine-core/spec/core/ObjectContainingSpec.js +64 -0
- data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +43 -42
- data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +147 -0
- data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +40 -0
- data/lib/jasmine-core/spec/core/SpecRunningSpec.js +92 -1075
- data/lib/jasmine-core/spec/core/SpecSpec.js +215 -95
- data/lib/jasmine-core/spec/core/SpySpec.js +28 -196
- data/lib/jasmine-core/spec/core/SpyStrategySpec.js +101 -0
- data/lib/jasmine-core/spec/core/SuiteSpec.js +216 -106
- data/lib/jasmine-core/spec/core/TimerSpec.js +13 -0
- data/lib/jasmine-core/spec/core/UtilSpec.js +19 -30
- data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +219 -0
- data/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js +51 -0
- data/lib/jasmine-core/spec/core/matchers/toBeDefinedSpec.js +18 -0
- data/lib/jasmine-core/spec/core/matchers/toBeFalsySpec.js +38 -0
- data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanSpec.js +19 -0
- data/lib/jasmine-core/spec/core/matchers/toBeLessThanSpec.js +20 -0
- data/lib/jasmine-core/spec/core/matchers/toBeNaNSpec.js +36 -0
- data/lib/jasmine-core/spec/core/matchers/toBeNullSpec.js +17 -0
- data/lib/jasmine-core/spec/core/matchers/toBeSpec.js +17 -0
- data/lib/jasmine-core/spec/core/matchers/toBeTruthySpec.js +38 -0
- data/lib/jasmine-core/spec/core/matchers/toBeUndefinedSpec.js +17 -0
- data/lib/jasmine-core/spec/core/matchers/toContainSpec.js +24 -0
- data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +28 -0
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js +46 -0
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledWithSpec.js +57 -0
- data/lib/jasmine-core/spec/core/matchers/toMatchSpec.js +34 -0
- data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +280 -0
- data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +98 -0
- data/lib/jasmine-core/spec/helpers/BrowserFlags.js +19 -0
- data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +494 -0
- data/lib/jasmine-core/spec/html/HtmlSpecFilterSpec.js +18 -0
- data/lib/jasmine-core/spec/html/MatchersHtmlSpec.js +8 -8
- data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +3 -3
- data/lib/jasmine-core/spec/html/QueryStringSpec.js +43 -0
- data/lib/jasmine-core/spec/html/ResultsNodeSpec.js +62 -0
- data/lib/jasmine-core/spec/node_suite.js +137 -79
- data/lib/jasmine-core/spec/performance/performance_test.js +10 -0
- data/lib/jasmine-core/spec/support/dev_boot.js +118 -0
- data/lib/jasmine-core/version.rb +5 -2
- metadata +47 -103
- data/lib/jasmine-core/example/SpecRunner.html +0 -54
- data/lib/jasmine-core/spec/core/BaseSpec.js +0 -27
- data/lib/jasmine-core/spec/core/MatchersSpec.js +0 -1157
- data/lib/jasmine-core/spec/core/MockClockSpec.js +0 -38
- data/lib/jasmine-core/spec/core/MultiReporterSpec.js +0 -45
- data/lib/jasmine-core/spec/core/NestedResultsSpec.js +0 -54
- data/lib/jasmine-core/spec/core/QueueSpec.js +0 -23
- data/lib/jasmine-core/spec/core/ReporterSpec.js +0 -56
- data/lib/jasmine-core/spec/core/RunnerSpec.js +0 -280
- data/lib/jasmine-core/spec/core/WaitsForBlockSpec.js +0 -118
- data/lib/jasmine-core/spec/html/HTMLReporterSpec.js +0 -209
- data/lib/jasmine-core/spec/html/TrivialReporterSpec.js +0 -239
@@ -1,39 +1,28 @@
|
|
1
|
-
describe("
|
2
|
-
describe("
|
3
|
-
it("should
|
4
|
-
|
5
|
-
|
6
|
-
foo: 'foo', bar: 'bar'
|
7
|
-
});
|
8
|
-
expect(destination).toEqual({foo: 'foo', bar: 'bar', baz: 'baz'});
|
1
|
+
describe("j$.util", function() {
|
2
|
+
describe("isArray_", function() {
|
3
|
+
it("should return true if the argument is an array", function() {
|
4
|
+
expect(j$.isArray_([])).toBe(true);
|
5
|
+
expect(j$.isArray_(['a'])).toBe(true);
|
9
6
|
});
|
10
7
|
|
11
|
-
it("should
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
expect(
|
17
|
-
|
18
|
-
foo: null
|
19
|
-
});
|
20
|
-
expect(destination).toEqual({foo: null});
|
8
|
+
it("should return false if the argument is not an array", function() {
|
9
|
+
expect(j$.isArray_(undefined)).toBe(false);
|
10
|
+
expect(j$.isArray_({})).toBe(false);
|
11
|
+
expect(j$.isArray_(function() {})).toBe(false);
|
12
|
+
expect(j$.isArray_('foo')).toBe(false);
|
13
|
+
expect(j$.isArray_(5)).toBe(false);
|
14
|
+
expect(j$.isArray_(null)).toBe(false);
|
21
15
|
});
|
22
16
|
});
|
23
17
|
|
24
|
-
describe("
|
25
|
-
it("
|
26
|
-
|
27
|
-
expect(
|
28
|
-
|
18
|
+
describe("isUndefined", function() {
|
19
|
+
it("reports if a variable is defined", function() {
|
20
|
+
var a;
|
21
|
+
expect(j$.util.isUndefined(a)).toBe(true);
|
22
|
+
expect(j$.util.isUndefined(undefined)).toBe(true);
|
29
23
|
|
30
|
-
|
31
|
-
expect(
|
32
|
-
expect(jasmine.isArray_({})).toBe(false);
|
33
|
-
expect(jasmine.isArray_(function() {})).toBe(false);
|
34
|
-
expect(jasmine.isArray_('foo')).toBe(false);
|
35
|
-
expect(jasmine.isArray_(5)).toBe(false);
|
36
|
-
expect(jasmine.isArray_(null)).toBe(false);
|
24
|
+
var undefined = "diz be undefined yo";
|
25
|
+
expect(j$.util.isUndefined(undefined)).toBe(false);
|
37
26
|
});
|
38
27
|
});
|
39
28
|
});
|
@@ -0,0 +1,219 @@
|
|
1
|
+
describe("matchersUtil", function() {
|
2
|
+
describe("equals", function() {
|
3
|
+
it("passes for literals that are threequal", function() {
|
4
|
+
expect(j$.matchersUtil.equals(null, null)).toBe(true);
|
5
|
+
expect(j$.matchersUtil.equals(void 0, void 0)).toBe(true);
|
6
|
+
});
|
7
|
+
|
8
|
+
it("fails for things that are not equivalent", function() {
|
9
|
+
expect(j$.matchersUtil.equals({a: "foo"}, 1)).toBe(false);
|
10
|
+
});
|
11
|
+
|
12
|
+
it("passes for Strings that are equivalent", function() {
|
13
|
+
expect(j$.matchersUtil.equals("foo", "foo")).toBe(true);
|
14
|
+
});
|
15
|
+
|
16
|
+
it("fails for Strings that are not equivalent", function() {
|
17
|
+
expect(j$.matchersUtil.equals("foo", "bar")).toBe(false);
|
18
|
+
});
|
19
|
+
|
20
|
+
it("passes for Numbers that are equivalent", function() {
|
21
|
+
expect(j$.matchersUtil.equals(123, 123)).toBe(true);
|
22
|
+
});
|
23
|
+
|
24
|
+
it("fails for Numbers that are not equivalent", function() {
|
25
|
+
expect(j$.matchersUtil.equals(123, 456)).toBe(false);
|
26
|
+
});
|
27
|
+
|
28
|
+
it("passes for Dates that are equivalent", function() {
|
29
|
+
expect(j$.matchersUtil.equals(new Date("Jan 1, 1970"), new Date("Jan 1, 1970"))).toBe(true);
|
30
|
+
});
|
31
|
+
|
32
|
+
it("fails for Dates that are not equivalent", function() {
|
33
|
+
expect(j$.matchersUtil.equals(new Date("Jan 1, 1970"), new Date("Feb 3, 1991"))).toBe(false);
|
34
|
+
});
|
35
|
+
|
36
|
+
it("passes for Booleans that are equivalent", function() {
|
37
|
+
expect(j$.matchersUtil.equals(true, true)).toBe(true);
|
38
|
+
});
|
39
|
+
|
40
|
+
it("fails for Booleans that are not equivalent", function() {
|
41
|
+
expect(j$.matchersUtil.equals(true, false)).toBe(false);
|
42
|
+
});
|
43
|
+
|
44
|
+
it("passes for RegExps that are equivalent", function() {
|
45
|
+
expect(j$.matchersUtil.equals(/foo/, /foo/)).toBe(true);
|
46
|
+
});
|
47
|
+
|
48
|
+
it("fails for RegExps that are not equivalent", function() {
|
49
|
+
expect(j$.matchersUtil.equals(/foo/, /bar/)).toBe(false);
|
50
|
+
expect(j$.matchersUtil.equals(new RegExp("foo", "i"), new RegExp("foo"))).toBe(false);
|
51
|
+
});
|
52
|
+
|
53
|
+
it("passes for Arrays that are equivalent", function() {
|
54
|
+
expect(j$.matchersUtil.equals([1, 2], [1, 2])).toBe(true);
|
55
|
+
});
|
56
|
+
|
57
|
+
it("fails for Arrays that are not equivalent", function() {
|
58
|
+
expect(j$.matchersUtil.equals([1, 2], [1, 2, 3])).toBe(false);
|
59
|
+
});
|
60
|
+
|
61
|
+
it("passes for Errors that are the same type and have the same message", function() {
|
62
|
+
expect(j$.matchersUtil.equals(new Error("foo"), new Error("foo"))).toBe(true);
|
63
|
+
});
|
64
|
+
|
65
|
+
it("fails for Errors that are the same type and have different messages", function() {
|
66
|
+
expect(j$.matchersUtil.equals(new Error("foo"), new Error("bar"))).toBe(false);
|
67
|
+
});
|
68
|
+
|
69
|
+
it("passes for Objects that are equivalent (simple case)", function() {
|
70
|
+
expect(j$.matchersUtil.equals({a: "foo"}, {a: "foo"})).toBe(true);
|
71
|
+
});
|
72
|
+
|
73
|
+
it("fails for Objects that are not equivalent (simple case)", function() {
|
74
|
+
expect(j$.matchersUtil.equals({a: "foo"}, {a: "bar"})).toBe(false);
|
75
|
+
});
|
76
|
+
|
77
|
+
it("passes for Objects that are equivalent (deep case)", function() {
|
78
|
+
expect(j$.matchersUtil.equals({a: "foo", b: { c: "bar"}}, {a: "foo", b: { c: "bar"}})).toBe(true);
|
79
|
+
});
|
80
|
+
|
81
|
+
it("fails for Objects that are not equivalent (deep case)", function() {
|
82
|
+
expect(j$.matchersUtil.equals({a: "foo", b: { c: "baz"}}, {a: "foo", b: { c: "bar"}})).toBe(false);
|
83
|
+
});
|
84
|
+
|
85
|
+
it("passes for Objects that are equivalent (with cycles)", function() {
|
86
|
+
var actual = { a: "foo" },
|
87
|
+
expected = { a: "foo" };
|
88
|
+
|
89
|
+
actual.b = actual;
|
90
|
+
expected.b = actual;
|
91
|
+
|
92
|
+
expect(j$.matchersUtil.equals(actual, expected)).toBe(true);
|
93
|
+
});
|
94
|
+
|
95
|
+
it("fails for Objects that are not equivalent (with cycles)", function() {
|
96
|
+
var actual = { a: "foo" },
|
97
|
+
expected = { a: "bar" };
|
98
|
+
|
99
|
+
actual.b = actual;
|
100
|
+
expected.b = actual;
|
101
|
+
|
102
|
+
expect(j$.matchersUtil.equals(actual, expected)).toBe(false);
|
103
|
+
});
|
104
|
+
|
105
|
+
it("fails when comparing an empty object to an empty array (issue #114)", function() {
|
106
|
+
var emptyObject = {},
|
107
|
+
emptyArray = [];
|
108
|
+
|
109
|
+
expect(j$.matchersUtil.equals(emptyObject, emptyArray)).toBe(false);
|
110
|
+
expect(j$.matchersUtil.equals(emptyArray, emptyObject)).toBe(false);
|
111
|
+
});
|
112
|
+
|
113
|
+
it("passes for equivalent frozen objects (GitHub issue #266)", function() {
|
114
|
+
if (jasmine.getEnv().ieVersion < 9) { return; }
|
115
|
+
|
116
|
+
var a = { foo: 1 },
|
117
|
+
b = {foo: 1 };
|
118
|
+
|
119
|
+
Object.freeze(a);
|
120
|
+
Object.freeze(b);
|
121
|
+
|
122
|
+
expect(j$.matchersUtil.equals(a,b)).toBe(true);
|
123
|
+
});
|
124
|
+
|
125
|
+
it("passes when Any is used", function() {
|
126
|
+
var number = 3,
|
127
|
+
anyNumber = new j$.Any(Number);
|
128
|
+
|
129
|
+
expect(j$.matchersUtil.equals(number, anyNumber)).toBe(true);
|
130
|
+
expect(j$.matchersUtil.equals(anyNumber, number)).toBe(true);
|
131
|
+
});
|
132
|
+
|
133
|
+
it("fails when Any is compared to something unexpected", function() {
|
134
|
+
var number = 3,
|
135
|
+
anyString = new j$.Any(String);
|
136
|
+
|
137
|
+
expect(j$.matchersUtil.equals(number, anyString)).toBe(false);
|
138
|
+
expect(j$.matchersUtil.equals(anyString, number)).toBe(false);
|
139
|
+
});
|
140
|
+
|
141
|
+
it("passes when ObjectContaining is used", function() {
|
142
|
+
var obj = {
|
143
|
+
foo: 3,
|
144
|
+
bar: 7
|
145
|
+
};
|
146
|
+
|
147
|
+
expect(j$.matchersUtil.equals(obj, new j$.ObjectContaining({foo: 3}))).toBe(true);
|
148
|
+
});
|
149
|
+
|
150
|
+
it("passes when a custom equality matcher returns true", function() {
|
151
|
+
var tester = function(a, b) { return true; };
|
152
|
+
|
153
|
+
expect(j$.matchersUtil.equals(1, 2, [tester])).toBe(true);
|
154
|
+
});
|
155
|
+
|
156
|
+
it("fails for equivalents when a custom equality matcher returns false", function() {
|
157
|
+
var tester = function(a, b) { return false; };
|
158
|
+
|
159
|
+
expect(j$.matchersUtil.equals(1, 2, [tester])).toBe(false);
|
160
|
+
});
|
161
|
+
});
|
162
|
+
|
163
|
+
describe("contains", function() {
|
164
|
+
it("passes when expected is a substring of actual", function() {
|
165
|
+
expect(j$.matchersUtil.contains("ABC", "B")).toBe(true);
|
166
|
+
});
|
167
|
+
|
168
|
+
it("fails when expected is a not substring of actual", function() {
|
169
|
+
expect(j$.matchersUtil.contains("ABC", "X")).toBe(false);
|
170
|
+
});
|
171
|
+
|
172
|
+
it("passes when expected is an element in an actual array", function() {
|
173
|
+
expect(j$.matchersUtil.contains(['foo', 'bar'], 'foo')).toBe(true);
|
174
|
+
});
|
175
|
+
|
176
|
+
it("fails when expected is not an element in an actual array", function() {
|
177
|
+
expect(j$.matchersUtil.contains(['foo', 'bar'], 'baz')).toBe(false);
|
178
|
+
});
|
179
|
+
|
180
|
+
it("passes with mixed-element arrays", function() {
|
181
|
+
expect(j$.matchersUtil.contains(["foo", {some: "bar"}], "foo")).toBe(true);
|
182
|
+
expect(j$.matchersUtil.contains(["foo", {some: "bar"}], {some: "bar"})).toBe(true);
|
183
|
+
});
|
184
|
+
|
185
|
+
it("uses custom equality testers if passed in and actual is an Array", function() {
|
186
|
+
var customTester = function(a, b) {return true;};
|
187
|
+
|
188
|
+
expect(j$.matchersUtil.contains([1, 2], 2, [customTester])).toBe(true);
|
189
|
+
});
|
190
|
+
});
|
191
|
+
|
192
|
+
describe("buildMessage", function() {
|
193
|
+
|
194
|
+
it("builds an English sentence for a failure case", function() {
|
195
|
+
var actual = "foo",
|
196
|
+
name = "toBar",
|
197
|
+
message = j$.matchersUtil.buildFailureMessage(name, false, actual);
|
198
|
+
|
199
|
+
expect(message).toEqual("Expected 'foo' to bar.");
|
200
|
+
});
|
201
|
+
|
202
|
+
it("builds an English sentence for a 'not' failure case", function() {
|
203
|
+
var actual = "foo",
|
204
|
+
name = "toBar",
|
205
|
+
isNot = true,
|
206
|
+
message = message = j$.matchersUtil.buildFailureMessage(name, isNot, actual);
|
207
|
+
|
208
|
+
expect(message).toEqual("Expected 'foo' not to bar.");
|
209
|
+
});
|
210
|
+
|
211
|
+
it("builds an English sentence for an arbitrary array of expected arguments", function() {
|
212
|
+
var actual = "foo",
|
213
|
+
name = "toBar",
|
214
|
+
message = j$.matchersUtil.buildFailureMessage(name, false, actual, "quux", "corge");
|
215
|
+
|
216
|
+
expect(message).toEqual("Expected 'foo' to bar 'quux', 'corge'.");
|
217
|
+
});
|
218
|
+
});
|
219
|
+
});
|
@@ -0,0 +1,51 @@
|
|
1
|
+
describe("toBeCloseTo", function() {
|
2
|
+
it("passes when within two decimal places by default", function() {
|
3
|
+
var matcher = j$.matchers.toBeCloseTo(),
|
4
|
+
result;
|
5
|
+
|
6
|
+
result = matcher.compare(0, 0);
|
7
|
+
expect(result.pass).toBe(true);
|
8
|
+
|
9
|
+
result = matcher.compare(0, 0.001);
|
10
|
+
expect(result.pass).toBe(true);
|
11
|
+
});
|
12
|
+
|
13
|
+
it("fails when not within two decimal places by default", function() {
|
14
|
+
var matcher = j$.matchers.toBeCloseTo(),
|
15
|
+
result;
|
16
|
+
|
17
|
+
result = matcher.compare(0, 0.01);
|
18
|
+
expect(result.pass).toBe(false);
|
19
|
+
});
|
20
|
+
|
21
|
+
it("accepts an optional precision argument", function() {
|
22
|
+
var matcher = j$.matchers.toBeCloseTo(),
|
23
|
+
result;
|
24
|
+
|
25
|
+
result = matcher.compare(0, 0.1, 0);
|
26
|
+
expect(result.pass).toBe(true);
|
27
|
+
|
28
|
+
result = matcher.compare(0, 0.0001, 3);
|
29
|
+
expect(result.pass).toBe(true);
|
30
|
+
});
|
31
|
+
|
32
|
+
it("rounds expected values", function() {
|
33
|
+
var matcher = j$.matchers.toBeCloseTo(),
|
34
|
+
result;
|
35
|
+
|
36
|
+
result = matcher.compare(1.23, 1.229);
|
37
|
+
expect(result.pass).toBe(true);
|
38
|
+
|
39
|
+
result = matcher.compare(1.23, 1.226);
|
40
|
+
expect(result.pass).toBe(true);
|
41
|
+
|
42
|
+
result = matcher.compare(1.23, 1.225);
|
43
|
+
expect(result.pass).toBe(true);
|
44
|
+
|
45
|
+
result = matcher.compare(1.23, 1.2249999);
|
46
|
+
expect(result.pass).toBe(false);
|
47
|
+
|
48
|
+
result = matcher.compare(1.23, 1.234);
|
49
|
+
expect(result.pass).toBe(true);
|
50
|
+
});
|
51
|
+
});
|
@@ -0,0 +1,18 @@
|
|
1
|
+
describe("toBeDefined", function() {
|
2
|
+
it("matches for defined values", function() {
|
3
|
+
var matcher = j$.matchers.toBeDefined(),
|
4
|
+
result;
|
5
|
+
|
6
|
+
|
7
|
+
result = matcher.compare('foo');
|
8
|
+
expect(result.pass).toBe(true);
|
9
|
+
});
|
10
|
+
|
11
|
+
it("fails when matching undefined values", function() {
|
12
|
+
var matcher = j$.matchers.toBeDefined(),
|
13
|
+
result;
|
14
|
+
|
15
|
+
result = matcher.compare(void 0);
|
16
|
+
expect(result.pass).toBe(false);
|
17
|
+
})
|
18
|
+
});
|
@@ -0,0 +1,38 @@
|
|
1
|
+
describe("toBeFalsy", function() {
|
2
|
+
it("passes for 'falsy' values", function() {
|
3
|
+
var matcher = j$.matchers.toBeFalsy(),
|
4
|
+
result;
|
5
|
+
|
6
|
+
result = matcher.compare(false);
|
7
|
+
expect(result.pass).toBe(true);
|
8
|
+
|
9
|
+
result = matcher.compare(0);
|
10
|
+
expect(result.pass).toBe(true);
|
11
|
+
|
12
|
+
result = matcher.compare('');
|
13
|
+
expect(result.pass).toBe(true);
|
14
|
+
|
15
|
+
result = matcher.compare(null);
|
16
|
+
expect(result.pass).toBe(true);
|
17
|
+
|
18
|
+
result = matcher.compare(void 0);
|
19
|
+
expect(result.pass).toBe(true);
|
20
|
+
});
|
21
|
+
|
22
|
+
it("fails for 'truthy' values", function() {
|
23
|
+
var matcher = j$.matchers.toBeFalsy(),
|
24
|
+
result;
|
25
|
+
|
26
|
+
result = matcher.compare(true);
|
27
|
+
expect(result.pass).toBe(false);
|
28
|
+
|
29
|
+
result = matcher.compare(1);
|
30
|
+
expect(result.pass).toBe(false);
|
31
|
+
|
32
|
+
result = matcher.compare("foo");
|
33
|
+
expect(result.pass).toBe(false);
|
34
|
+
|
35
|
+
result = matcher.compare({});
|
36
|
+
expect(result.pass).toBe(false);
|
37
|
+
});
|
38
|
+
});
|
@@ -0,0 +1,19 @@
|
|
1
|
+
describe("toBeGreaterThan", function() {
|
2
|
+
it("passes when actual > expected", function() {
|
3
|
+
var matcher = j$.matchers.toBeGreaterThan(),
|
4
|
+
result;
|
5
|
+
|
6
|
+
result = matcher.compare(2, 1);
|
7
|
+
expect(result.pass).toBe(true);
|
8
|
+
});
|
9
|
+
|
10
|
+
it("fails when actual <= expected", function() {
|
11
|
+
var matcher = j$.matchers.toBeGreaterThan();
|
12
|
+
|
13
|
+
result = matcher.compare(1, 1);
|
14
|
+
expect(result.pass).toBe(false);
|
15
|
+
|
16
|
+
result = matcher.compare(1, 2);
|
17
|
+
expect(result.pass).toBe(false);
|
18
|
+
});
|
19
|
+
});
|
@@ -0,0 +1,20 @@
|
|
1
|
+
describe("toBeLessThan", function() {
|
2
|
+
it("passes when actual < expected", function() {
|
3
|
+
var matcher = j$.matchers.toBeLessThan(),
|
4
|
+
result;
|
5
|
+
|
6
|
+
result = matcher.compare(1, 2);
|
7
|
+
expect(result.pass).toBe(true);
|
8
|
+
});
|
9
|
+
|
10
|
+
it("fails when actual <= expected", function() {
|
11
|
+
var matcher = j$.matchers.toBeLessThan(),
|
12
|
+
result;
|
13
|
+
|
14
|
+
result = matcher.compare(1, 1);
|
15
|
+
expect(result.pass).toBe(false);
|
16
|
+
|
17
|
+
result = matcher.compare(2, 1);
|
18
|
+
expect(result.pass).toBe(false);
|
19
|
+
});
|
20
|
+
});
|
@@ -0,0 +1,36 @@
|
|
1
|
+
describe("toBeNaN", function() {
|
2
|
+
it("passes for NaN with a custom .not fail", function() {
|
3
|
+
var matcher = j$.matchers.toBeNaN(),
|
4
|
+
result;
|
5
|
+
|
6
|
+
result = matcher.compare(Number.NaN);
|
7
|
+
expect(result.pass).toBe(true);
|
8
|
+
expect(result.message).toEqual("Expected actual not to be NaN.");
|
9
|
+
});
|
10
|
+
|
11
|
+
it("fails for anything not a NaN", function() {
|
12
|
+
var matcher = j$.matchers.toBeNaN();
|
13
|
+
|
14
|
+
result = matcher.compare(1);
|
15
|
+
expect(result.pass).toBe(false);
|
16
|
+
|
17
|
+
result = matcher.compare(null);
|
18
|
+
expect(result.pass).toBe(false);
|
19
|
+
|
20
|
+
result = matcher.compare(void 0);
|
21
|
+
expect(result.pass).toBe(false);
|
22
|
+
|
23
|
+
result = matcher.compare('');
|
24
|
+
expect(result.pass).toBe(false);
|
25
|
+
|
26
|
+
result = matcher.compare(Number.POSITIVE_INFINITY);
|
27
|
+
expect(result.pass).toBe(false);
|
28
|
+
});
|
29
|
+
|
30
|
+
it("has a custom message on failure", function() {
|
31
|
+
var matcher = j$.matchers.toBeNaN(),
|
32
|
+
result = matcher.compare(0);
|
33
|
+
|
34
|
+
expect(result.message).toEqual("Expected 0 to be NaN.");
|
35
|
+
});
|
36
|
+
});
|