jasmine-core 2.99.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jasmine-core/boot.js +7 -6
- data/lib/jasmine-core/boot/boot.js +7 -6
- data/lib/jasmine-core/boot/node_boot.js +0 -3
- data/lib/jasmine-core/jasmine-html.js +228 -137
- data/lib/jasmine-core/jasmine.css +11 -5
- data/lib/jasmine-core/jasmine.js +1046 -608
- data/lib/jasmine-core/node_boot.js +0 -3
- data/lib/jasmine-core/spec/core/CallTrackerSpec.js +130 -0
- data/lib/jasmine-core/spec/core/ClearStackSpec.js +137 -0
- data/lib/jasmine-core/spec/core/ClockSpec.js +710 -0
- data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +286 -0
- data/lib/jasmine-core/spec/core/EnvSpec.js +200 -0
- data/lib/jasmine-core/spec/core/ExceptionFormatterSpec.js +120 -0
- data/lib/jasmine-core/spec/core/ExceptionsSpec.js +46 -0
- data/lib/jasmine-core/spec/core/ExpectationResultSpec.js +61 -0
- data/lib/jasmine-core/spec/core/ExpectationSpec.js +434 -0
- data/lib/jasmine-core/spec/core/GlobalErrorsSpec.js +110 -0
- data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +259 -0
- data/lib/jasmine-core/spec/core/MockDateSpec.js +200 -0
- data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +332 -0
- data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +670 -0
- data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +140 -0
- data/lib/jasmine-core/spec/core/SpecSpec.js +407 -0
- data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +364 -0
- data/lib/jasmine-core/spec/core/SpySpec.js +177 -0
- data/lib/jasmine-core/spec/core/SpyStrategySpec.js +202 -0
- data/lib/jasmine-core/spec/core/StackTraceSpec.js +166 -0
- data/lib/jasmine-core/spec/core/SuiteSpec.js +123 -0
- data/lib/jasmine-core/spec/core/TimerSpec.js +31 -0
- data/lib/jasmine-core/spec/core/TreeProcessorSpec.js +794 -0
- data/lib/jasmine-core/spec/core/UserContextSpec.js +54 -0
- data/lib/jasmine-core/spec/core/UtilSpec.js +105 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/AnySpec.js +91 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/AnythingSpec.js +76 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayContainingSpec.js +52 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js +47 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js +99 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/StringMatchingSpec.js +27 -0
- data/lib/jasmine-core/spec/core/formatErrorMsgSpec.js +13 -0
- data/lib/jasmine-core/spec/core/integration/CustomMatchersSpec.js +200 -0
- data/lib/jasmine-core/spec/core/integration/CustomSpyStrategiesSpec.js +138 -0
- data/lib/jasmine-core/spec/core/integration/EnvSpec.js +2344 -0
- data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +976 -0
- data/lib/jasmine-core/spec/core/matchers/DiffBuilderSpec.js +47 -0
- data/lib/jasmine-core/spec/core/matchers/NullDiffBuilderSpec.js +13 -0
- data/lib/jasmine-core/spec/core/matchers/ObjectPathSpec.js +43 -0
- data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +645 -0
- data/lib/jasmine-core/spec/core/matchers/nothingSpec.js +8 -0
- data/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js +93 -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/toBeGreaterThanOrEqualSpec.js +29 -0
- data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanSpec.js +20 -0
- data/lib/jasmine-core/spec/core/matchers/toBeLessThanOrEqualSpec.js +29 -0
- data/lib/jasmine-core/spec/core/matchers/toBeLessThanSpec.js +20 -0
- data/lib/jasmine-core/spec/core/matchers/toBeNaNSpec.js +37 -0
- data/lib/jasmine-core/spec/core/matchers/toBeNegativeInfinitySpec.js +31 -0
- data/lib/jasmine-core/spec/core/matchers/toBeNullSpec.js +17 -0
- data/lib/jasmine-core/spec/core/matchers/toBePositiveInfinitySpec.js +31 -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 +18 -0
- data/lib/jasmine-core/spec/core/matchers/toContainSpec.js +26 -0
- data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +785 -0
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledBeforeSpec.js +99 -0
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js +47 -0
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledTimesSpec.js +86 -0
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledWithSpec.js +67 -0
- data/lib/jasmine-core/spec/core/matchers/toMatchSpec.js +43 -0
- data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +315 -0
- data/lib/jasmine-core/spec/core/matchers/toThrowMatchingSpec.js +73 -0
- data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +100 -0
- data/lib/jasmine-core/spec/helpers/BrowserFlags.js +15 -0
- data/lib/jasmine-core/spec/helpers/asyncAwait.js +27 -0
- data/lib/jasmine-core/spec/helpers/checkForMap.js +37 -0
- data/lib/jasmine-core/spec/helpers/checkForSet.js +41 -0
- data/lib/jasmine-core/spec/helpers/checkForSymbol.js +28 -0
- data/lib/jasmine-core/spec/helpers/checkForTypedArrays.js +20 -0
- data/lib/jasmine-core/spec/helpers/defineJasmineUnderTest.js +6 -0
- data/lib/jasmine-core/spec/helpers/integrationMatchers.js +43 -0
- data/lib/jasmine-core/spec/helpers/nodeDefineJasmineUnderTest.js +30 -0
- data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +1261 -0
- data/lib/jasmine-core/spec/html/HtmlSpecFilterSpec.js +18 -0
- data/lib/jasmine-core/spec/html/MatchersHtmlSpec.js +37 -0
- data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +27 -0
- data/lib/jasmine-core/spec/html/QueryStringSpec.js +72 -0
- data/lib/jasmine-core/spec/html/ResultsNodeSpec.js +62 -0
- data/lib/jasmine-core/spec/html/SpyRegistryHtmlSpec.js +39 -0
- data/lib/jasmine-core/spec/html/matchers/toHaveClassSpec.js +48 -0
- data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +101 -0
- data/lib/jasmine-core/spec/performance/large_object_test.js +36 -0
- data/lib/jasmine-core/spec/performance/performance_test.js +10 -0
- data/lib/jasmine-core/version.rb +1 -1
- metadata +88 -4
- data/lib/console/console.js +0 -190
@@ -0,0 +1,93 @@
|
|
1
|
+
describe("toBeCloseTo", function() {
|
2
|
+
it("passes when within two decimal places by default", function() {
|
3
|
+
var matcher = jasmineUnderTest.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
|
+
result = matcher.compare(0, 0.005);
|
13
|
+
expect(result.pass).toBe(true);
|
14
|
+
});
|
15
|
+
|
16
|
+
it("fails when not within two decimal places by default", function() {
|
17
|
+
var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
|
18
|
+
result;
|
19
|
+
|
20
|
+
result = matcher.compare(0, 0.01);
|
21
|
+
expect(result.pass).toBe(false);
|
22
|
+
|
23
|
+
result = matcher.compare(0, 0.05);
|
24
|
+
expect(result.pass).toBe(false);
|
25
|
+
});
|
26
|
+
|
27
|
+
it("accepts an optional precision argument", function() {
|
28
|
+
var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
|
29
|
+
result;
|
30
|
+
|
31
|
+
result = matcher.compare(0, 0.1, 0);
|
32
|
+
expect(result.pass).toBe(true);
|
33
|
+
|
34
|
+
result = matcher.compare(0, 0.5, 0);
|
35
|
+
expect(result.pass).toBe(true);
|
36
|
+
|
37
|
+
result = matcher.compare(0, 0.0001, 3);
|
38
|
+
expect(result.pass).toBe(true);
|
39
|
+
|
40
|
+
result = matcher.compare(0, 0.0005, 3);
|
41
|
+
expect(result.pass).toBe(true);
|
42
|
+
|
43
|
+
result = matcher.compare(0, 0.00001, 4);
|
44
|
+
expect(result.pass).toBe(true);
|
45
|
+
|
46
|
+
result = matcher.compare(0, 0.00005, 4);
|
47
|
+
expect(result.pass).toBe(true);
|
48
|
+
});
|
49
|
+
|
50
|
+
it("fails when one of the arguments is null", function() {
|
51
|
+
var matcher = jasmineUnderTest.matchers.toBeCloseTo();
|
52
|
+
|
53
|
+
expect(function() {
|
54
|
+
matcher.compare(null, null);
|
55
|
+
}).toThrowError('Cannot use toBeCloseTo with null. Arguments evaluated to: expect(null).toBeCloseTo(null).');
|
56
|
+
|
57
|
+
expect(function() {
|
58
|
+
matcher.compare(0, null);
|
59
|
+
}).toThrowError('Cannot use toBeCloseTo with null. Arguments evaluated to: expect(0).toBeCloseTo(null).');
|
60
|
+
|
61
|
+
expect(function() {
|
62
|
+
matcher.compare(null, 0);
|
63
|
+
}).toThrowError('Cannot use toBeCloseTo with null. Arguments evaluated to: expect(null).toBeCloseTo(0).');
|
64
|
+
});
|
65
|
+
|
66
|
+
it("rounds expected values", function() {
|
67
|
+
var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
|
68
|
+
result;
|
69
|
+
|
70
|
+
result = matcher.compare(1.23, 1.229);
|
71
|
+
expect(result.pass).toBe(true);
|
72
|
+
|
73
|
+
result = matcher.compare(1.23, 1.226);
|
74
|
+
expect(result.pass).toBe(true);
|
75
|
+
|
76
|
+
result = matcher.compare(1.23, 1.225);
|
77
|
+
expect(result.pass).toBe(true);
|
78
|
+
|
79
|
+
result = matcher.compare(1.23, 1.235);
|
80
|
+
expect(result.pass).toBe(true);
|
81
|
+
|
82
|
+
// 1.2249999 will be rounded to 1.225
|
83
|
+
result = matcher.compare(1.23, 1.2249999);
|
84
|
+
expect(result.pass).toBe(true);
|
85
|
+
|
86
|
+
// 1.2249999 will be rounded to 1.224
|
87
|
+
result = matcher.compare(1.23, 1.2244999);
|
88
|
+
expect(result.pass).toBe(false);
|
89
|
+
|
90
|
+
result = matcher.compare(1.23, 1.234);
|
91
|
+
expect(result.pass).toBe(true);
|
92
|
+
});
|
93
|
+
});
|
@@ -0,0 +1,18 @@
|
|
1
|
+
describe("toBeDefined", function() {
|
2
|
+
it("matches for defined values", function() {
|
3
|
+
var matcher = jasmineUnderTest.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 = jasmineUnderTest.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 = jasmineUnderTest.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 = jasmineUnderTest.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,29 @@
|
|
1
|
+
describe("toBeGreaterThanOrEqual", function() {
|
2
|
+
it("passes when actual >= expected", function() {
|
3
|
+
var matcher = jasmineUnderTest.matchers.toBeGreaterThanOrEqual(),
|
4
|
+
result;
|
5
|
+
|
6
|
+
result = matcher.compare(2, 1);
|
7
|
+
expect(result.pass).toBe(true);
|
8
|
+
|
9
|
+
result = matcher.compare(1, 1);
|
10
|
+
expect(result.pass).toBe(true);
|
11
|
+
|
12
|
+
result = matcher.compare(1.0000001, 1);
|
13
|
+
expect(result.pass).toBe(true);
|
14
|
+
|
15
|
+
result = matcher.compare(1.0, 1.0);
|
16
|
+
expect(result.pass).toBe(true);
|
17
|
+
})
|
18
|
+
|
19
|
+
it("fails when actual < expected", function() {
|
20
|
+
var matcher = jasmineUnderTest.matchers.toBeGreaterThanOrEqual(),
|
21
|
+
result;
|
22
|
+
|
23
|
+
result = matcher.compare(1, 2);
|
24
|
+
expect(result.pass).toBe(false);
|
25
|
+
|
26
|
+
result = matcher.compare(1, 1.0000001);
|
27
|
+
expect(result.pass).toBe(false);
|
28
|
+
})
|
29
|
+
});
|
@@ -0,0 +1,20 @@
|
|
1
|
+
describe("toBeGreaterThan", function() {
|
2
|
+
it("passes when actual > expected", function() {
|
3
|
+
var matcher = jasmineUnderTest.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 = jasmineUnderTest.matchers.toBeGreaterThan(),
|
12
|
+
result;
|
13
|
+
|
14
|
+
result = matcher.compare(1, 1);
|
15
|
+
expect(result.pass).toBe(false);
|
16
|
+
|
17
|
+
result = matcher.compare(1, 2);
|
18
|
+
expect(result.pass).toBe(false);
|
19
|
+
});
|
20
|
+
});
|
@@ -0,0 +1,29 @@
|
|
1
|
+
describe("toBeLessThanOrEqual", function() {
|
2
|
+
it("passes when actual <= expected", function() {
|
3
|
+
var matcher = jasmineUnderTest.matchers.toBeLessThanOrEqual(),
|
4
|
+
result;
|
5
|
+
|
6
|
+
result = matcher.compare(1, 2);
|
7
|
+
expect(result.pass).toBe(true);
|
8
|
+
|
9
|
+
result = matcher.compare(1, 1);
|
10
|
+
expect(result.pass).toBe(true);
|
11
|
+
|
12
|
+
result = matcher.compare(1, 1.0000001);
|
13
|
+
expect(result.pass).toBe(true);
|
14
|
+
|
15
|
+
result = matcher.compare(1.0, 1.0);
|
16
|
+
expect(result.pass).toBe(true);
|
17
|
+
});
|
18
|
+
|
19
|
+
it("fails when actual < expected", function() {
|
20
|
+
var matcher = jasmineUnderTest.matchers.toBeLessThanOrEqual(),
|
21
|
+
result;
|
22
|
+
|
23
|
+
result = matcher.compare(2, 1);
|
24
|
+
expect(result.pass).toBe(false);
|
25
|
+
|
26
|
+
result = matcher.compare(1.0000001, 1);
|
27
|
+
expect(result.pass).toBe(false);
|
28
|
+
});
|
29
|
+
});
|
@@ -0,0 +1,20 @@
|
|
1
|
+
describe("toBeLessThan", function() {
|
2
|
+
it("passes when actual < expected", function() {
|
3
|
+
var matcher = jasmineUnderTest.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 = jasmineUnderTest.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,37 @@
|
|
1
|
+
describe("toBeNaN", function() {
|
2
|
+
it("passes for NaN with a custom .not fail", function() {
|
3
|
+
var matcher = jasmineUnderTest.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 = jasmineUnderTest.matchers.toBeNaN(),
|
13
|
+
result;
|
14
|
+
|
15
|
+
result = matcher.compare(1);
|
16
|
+
expect(result.pass).toBe(false);
|
17
|
+
|
18
|
+
result = matcher.compare(null);
|
19
|
+
expect(result.pass).toBe(false);
|
20
|
+
|
21
|
+
result = matcher.compare(void 0);
|
22
|
+
expect(result.pass).toBe(false);
|
23
|
+
|
24
|
+
result = matcher.compare('');
|
25
|
+
expect(result.pass).toBe(false);
|
26
|
+
|
27
|
+
result = matcher.compare(Number.POSITIVE_INFINITY);
|
28
|
+
expect(result.pass).toBe(false);
|
29
|
+
});
|
30
|
+
|
31
|
+
it("has a custom message on failure", function() {
|
32
|
+
var matcher = jasmineUnderTest.matchers.toBeNaN(),
|
33
|
+
result = matcher.compare(0);
|
34
|
+
|
35
|
+
expect(result.message()).toEqual("Expected 0 to be NaN.");
|
36
|
+
});
|
37
|
+
});
|
@@ -0,0 +1,31 @@
|
|
1
|
+
describe("toBeNegativeInfinity", function() {
|
2
|
+
it("fails for anything that isn't -Infinity", function() {
|
3
|
+
var matcher = jasmineUnderTest.matchers.toBeNegativeInfinity(),
|
4
|
+
result;
|
5
|
+
|
6
|
+
result = matcher.compare(1);
|
7
|
+
expect(result.pass).toBe(false);
|
8
|
+
|
9
|
+
result = matcher.compare(Number.NaN);
|
10
|
+
expect(result.pass).toBe(false);
|
11
|
+
|
12
|
+
result = matcher.compare(null);
|
13
|
+
expect(result.pass).toBe(false);
|
14
|
+
});
|
15
|
+
|
16
|
+
it("has a custom message on failure", function() {
|
17
|
+
var matcher = jasmineUnderTest.matchers.toBeNegativeInfinity(),
|
18
|
+
result = matcher.compare(0);
|
19
|
+
|
20
|
+
expect(result.message()).toEqual("Expected 0 not to be -Infinity.")
|
21
|
+
});
|
22
|
+
|
23
|
+
it("succeeds for -Infinity", function() {
|
24
|
+
var matcher = jasmineUnderTest.matchers.toBeNegativeInfinity(),
|
25
|
+
result = matcher.compare(Number.NEGATIVE_INFINITY);
|
26
|
+
|
27
|
+
expect(result.pass).toBe(true);
|
28
|
+
expect(result.message).toEqual("Expected actual to be -Infinity.")
|
29
|
+
});
|
30
|
+
|
31
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
describe("toBeNull", function() {
|
2
|
+
it("passes for null", function() {
|
3
|
+
var matcher = jasmineUnderTest.matchers.toBeNull(),
|
4
|
+
result;
|
5
|
+
|
6
|
+
result = matcher.compare(null);
|
7
|
+
expect(result.pass).toBe(true);
|
8
|
+
});
|
9
|
+
|
10
|
+
it("fails for non-null", function() {
|
11
|
+
var matcher = jasmineUnderTest.matchers.toBeNull(),
|
12
|
+
result;
|
13
|
+
|
14
|
+
result = matcher.compare('foo');
|
15
|
+
expect(result.pass).toBe(false);
|
16
|
+
});
|
17
|
+
});
|
@@ -0,0 +1,31 @@
|
|
1
|
+
describe("toBePositiveInfinity", function() {
|
2
|
+
it("fails for anything that isn't Infinity", function() {
|
3
|
+
var matcher = jasmineUnderTest.matchers.toBePositiveInfinity(),
|
4
|
+
result;
|
5
|
+
|
6
|
+
result = matcher.compare(1);
|
7
|
+
expect(result.pass).toBe(false);
|
8
|
+
|
9
|
+
result = matcher.compare(Number.NaN);
|
10
|
+
expect(result.pass).toBe(false);
|
11
|
+
|
12
|
+
result = matcher.compare(null);
|
13
|
+
expect(result.pass).toBe(false);
|
14
|
+
});
|
15
|
+
|
16
|
+
it("has a custom message on failure", function() {
|
17
|
+
var matcher = jasmineUnderTest.matchers.toBePositiveInfinity(),
|
18
|
+
result = matcher.compare(0);
|
19
|
+
|
20
|
+
expect(result.message()).toEqual("Expected 0 not to be Infinity.")
|
21
|
+
});
|
22
|
+
|
23
|
+
it("succeeds for Infinity", function() {
|
24
|
+
var matcher = jasmineUnderTest.matchers.toBePositiveInfinity(),
|
25
|
+
result = matcher.compare(Number.POSITIVE_INFINITY);
|
26
|
+
|
27
|
+
expect(result.pass).toBe(true);
|
28
|
+
expect(result.message).toEqual("Expected actual to be Infinity.")
|
29
|
+
});
|
30
|
+
|
31
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
describe("toBe", function() {
|
2
|
+
it("passes when actual === expected", function() {
|
3
|
+
var matcher = jasmineUnderTest.matchers.toBe(),
|
4
|
+
result;
|
5
|
+
|
6
|
+
result = matcher.compare(1, 1);
|
7
|
+
expect(result.pass).toBe(true);
|
8
|
+
});
|
9
|
+
|
10
|
+
it("fails when actual !== expected", function() {
|
11
|
+
var matcher = jasmineUnderTest.matchers.toBe(),
|
12
|
+
result;
|
13
|
+
|
14
|
+
result = matcher.compare(1, 2);
|
15
|
+
expect(result.pass).toBe(false);
|
16
|
+
});
|
17
|
+
});
|
@@ -0,0 +1,38 @@
|
|
1
|
+
describe("toBeTruthy", function() {
|
2
|
+
it("passes for 'truthy' values", function() {
|
3
|
+
var matcher = jasmineUnderTest.matchers.toBeTruthy(),
|
4
|
+
result;
|
5
|
+
|
6
|
+
result = matcher.compare(true);
|
7
|
+
expect(result.pass).toBe(true);
|
8
|
+
|
9
|
+
result = matcher.compare(1);
|
10
|
+
expect(result.pass).toBe(true);
|
11
|
+
|
12
|
+
result = matcher.compare("foo");
|
13
|
+
expect(result.pass).toBe(true);
|
14
|
+
|
15
|
+
result = matcher.compare({});
|
16
|
+
expect(result.pass).toBe(true);
|
17
|
+
});
|
18
|
+
|
19
|
+
it("fails for 'falsy' values", function() {
|
20
|
+
var matcher = jasmineUnderTest.matchers.toBeTruthy(),
|
21
|
+
result;
|
22
|
+
|
23
|
+
result = matcher.compare(false);
|
24
|
+
expect(result.pass).toBe(false);
|
25
|
+
|
26
|
+
result = matcher.compare(0);
|
27
|
+
expect(result.pass).toBe(false);
|
28
|
+
|
29
|
+
result = matcher.compare('');
|
30
|
+
expect(result.pass).toBe(false);
|
31
|
+
|
32
|
+
result = matcher.compare(null);
|
33
|
+
expect(result.pass).toBe(false);
|
34
|
+
|
35
|
+
result = matcher.compare(void 0);
|
36
|
+
expect(result.pass).toBe(false);
|
37
|
+
});
|
38
|
+
});
|