jasmine-core 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/jasmine-core/boot/node_boot.js +1 -1
- data/lib/jasmine-core/jasmine-html.js +0 -35
- data/lib/jasmine-core/jasmine.css +0 -6
- data/lib/jasmine-core/jasmine.js +246 -36
- data/lib/jasmine-core/node_boot.js +1 -1
- data/lib/jasmine-core/version.rb +1 -1
- metadata +3 -88
- data/lib/jasmine-core/spec/core/CallTrackerSpec.js +0 -130
- data/lib/jasmine-core/spec/core/ClearStackSpec.js +0 -137
- data/lib/jasmine-core/spec/core/ClockSpec.js +0 -710
- data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +0 -286
- data/lib/jasmine-core/spec/core/EnvSpec.js +0 -200
- data/lib/jasmine-core/spec/core/ExceptionFormatterSpec.js +0 -120
- data/lib/jasmine-core/spec/core/ExceptionsSpec.js +0 -46
- data/lib/jasmine-core/spec/core/ExpectationResultSpec.js +0 -61
- data/lib/jasmine-core/spec/core/ExpectationSpec.js +0 -434
- data/lib/jasmine-core/spec/core/GlobalErrorsSpec.js +0 -110
- data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +0 -259
- data/lib/jasmine-core/spec/core/MockDateSpec.js +0 -200
- data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +0 -332
- data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +0 -670
- data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +0 -140
- data/lib/jasmine-core/spec/core/SpecSpec.js +0 -407
- data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +0 -364
- data/lib/jasmine-core/spec/core/SpySpec.js +0 -177
- data/lib/jasmine-core/spec/core/SpyStrategySpec.js +0 -202
- data/lib/jasmine-core/spec/core/StackTraceSpec.js +0 -166
- data/lib/jasmine-core/spec/core/SuiteSpec.js +0 -123
- data/lib/jasmine-core/spec/core/TimerSpec.js +0 -31
- data/lib/jasmine-core/spec/core/TreeProcessorSpec.js +0 -794
- data/lib/jasmine-core/spec/core/UserContextSpec.js +0 -54
- data/lib/jasmine-core/spec/core/UtilSpec.js +0 -105
- data/lib/jasmine-core/spec/core/asymmetric_equality/AnySpec.js +0 -91
- data/lib/jasmine-core/spec/core/asymmetric_equality/AnythingSpec.js +0 -76
- data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayContainingSpec.js +0 -52
- data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js +0 -47
- data/lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js +0 -99
- data/lib/jasmine-core/spec/core/asymmetric_equality/StringMatchingSpec.js +0 -27
- data/lib/jasmine-core/spec/core/formatErrorMsgSpec.js +0 -13
- data/lib/jasmine-core/spec/core/integration/CustomMatchersSpec.js +0 -200
- data/lib/jasmine-core/spec/core/integration/CustomSpyStrategiesSpec.js +0 -138
- data/lib/jasmine-core/spec/core/integration/EnvSpec.js +0 -2344
- data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +0 -976
- data/lib/jasmine-core/spec/core/matchers/DiffBuilderSpec.js +0 -47
- data/lib/jasmine-core/spec/core/matchers/NullDiffBuilderSpec.js +0 -13
- data/lib/jasmine-core/spec/core/matchers/ObjectPathSpec.js +0 -43
- data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +0 -645
- data/lib/jasmine-core/spec/core/matchers/nothingSpec.js +0 -8
- data/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js +0 -93
- data/lib/jasmine-core/spec/core/matchers/toBeDefinedSpec.js +0 -18
- data/lib/jasmine-core/spec/core/matchers/toBeFalsySpec.js +0 -38
- data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanOrEqualSpec.js +0 -29
- data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanSpec.js +0 -20
- data/lib/jasmine-core/spec/core/matchers/toBeLessThanOrEqualSpec.js +0 -29
- data/lib/jasmine-core/spec/core/matchers/toBeLessThanSpec.js +0 -20
- data/lib/jasmine-core/spec/core/matchers/toBeNaNSpec.js +0 -37
- data/lib/jasmine-core/spec/core/matchers/toBeNegativeInfinitySpec.js +0 -31
- data/lib/jasmine-core/spec/core/matchers/toBeNullSpec.js +0 -17
- data/lib/jasmine-core/spec/core/matchers/toBePositiveInfinitySpec.js +0 -31
- data/lib/jasmine-core/spec/core/matchers/toBeSpec.js +0 -17
- data/lib/jasmine-core/spec/core/matchers/toBeTruthySpec.js +0 -38
- data/lib/jasmine-core/spec/core/matchers/toBeUndefinedSpec.js +0 -18
- data/lib/jasmine-core/spec/core/matchers/toContainSpec.js +0 -26
- data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +0 -785
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledBeforeSpec.js +0 -99
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js +0 -47
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledTimesSpec.js +0 -86
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledWithSpec.js +0 -67
- data/lib/jasmine-core/spec/core/matchers/toMatchSpec.js +0 -43
- data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +0 -315
- data/lib/jasmine-core/spec/core/matchers/toThrowMatchingSpec.js +0 -73
- data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +0 -100
- data/lib/jasmine-core/spec/helpers/BrowserFlags.js +0 -15
- data/lib/jasmine-core/spec/helpers/asyncAwait.js +0 -27
- data/lib/jasmine-core/spec/helpers/checkForMap.js +0 -37
- data/lib/jasmine-core/spec/helpers/checkForSet.js +0 -41
- data/lib/jasmine-core/spec/helpers/checkForSymbol.js +0 -28
- data/lib/jasmine-core/spec/helpers/checkForTypedArrays.js +0 -20
- data/lib/jasmine-core/spec/helpers/defineJasmineUnderTest.js +0 -6
- data/lib/jasmine-core/spec/helpers/integrationMatchers.js +0 -43
- data/lib/jasmine-core/spec/helpers/nodeDefineJasmineUnderTest.js +0 -30
- data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +0 -1261
- data/lib/jasmine-core/spec/html/HtmlSpecFilterSpec.js +0 -18
- data/lib/jasmine-core/spec/html/MatchersHtmlSpec.js +0 -37
- data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +0 -27
- data/lib/jasmine-core/spec/html/QueryStringSpec.js +0 -72
- data/lib/jasmine-core/spec/html/ResultsNodeSpec.js +0 -62
- data/lib/jasmine-core/spec/html/SpyRegistryHtmlSpec.js +0 -39
- data/lib/jasmine-core/spec/html/matchers/toHaveClassSpec.js +0 -48
- data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +0 -101
- data/lib/jasmine-core/spec/performance/large_object_test.js +0 -36
- data/lib/jasmine-core/spec/performance/performance_test.js +0 -10
@@ -1,99 +0,0 @@
|
|
1
|
-
describe("toHaveBeenCalledBefore", function() {
|
2
|
-
it("throws an exception when the actual is not a spy", function() {
|
3
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
|
4
|
-
fn = function() {},
|
5
|
-
secondSpy = new jasmineUnderTest.Env().createSpy('second spy');
|
6
|
-
|
7
|
-
expect(function() { matcher.compare(fn, secondSpy) }).toThrowError(Error, /Expected a spy, but got Function./);
|
8
|
-
});
|
9
|
-
|
10
|
-
it("throws an exception when the expected is not a spy", function() {
|
11
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
|
12
|
-
firstSpy = new jasmineUnderTest.Env().createSpy('first spy'),
|
13
|
-
fn = function() {};
|
14
|
-
|
15
|
-
expect(function() { matcher.compare(firstSpy, fn) }).toThrowError(Error, /Expected a spy, but got Function./);
|
16
|
-
});
|
17
|
-
|
18
|
-
it("fails when the actual was not called", function() {
|
19
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
|
20
|
-
firstSpy = new jasmineUnderTest.Env().createSpy('first spy'),
|
21
|
-
secondSpy = new jasmineUnderTest.Env().createSpy('second spy');
|
22
|
-
|
23
|
-
secondSpy();
|
24
|
-
|
25
|
-
result = matcher.compare(firstSpy, secondSpy);
|
26
|
-
expect(result.pass).toBe(false);
|
27
|
-
expect(result.message).toMatch(/Expected spy first spy to have been called./);
|
28
|
-
});
|
29
|
-
|
30
|
-
it("fails when the expected was not called", function() {
|
31
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
|
32
|
-
firstSpy = new jasmineUnderTest.Env().createSpy('first spy'),
|
33
|
-
secondSpy = new jasmineUnderTest.Env().createSpy('second spy');
|
34
|
-
|
35
|
-
firstSpy();
|
36
|
-
|
37
|
-
result = matcher.compare(firstSpy, secondSpy);
|
38
|
-
expect(result.pass).toBe(false);
|
39
|
-
expect(result.message).toMatch(/Expected spy second spy to have been called./);
|
40
|
-
});
|
41
|
-
|
42
|
-
it("fails when the actual is called after the expected", function() {
|
43
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
|
44
|
-
firstSpy = new jasmineUnderTest.Env().createSpy('first spy'),
|
45
|
-
secondSpy = new jasmineUnderTest.Env().createSpy('second spy'),
|
46
|
-
result;
|
47
|
-
|
48
|
-
secondSpy();
|
49
|
-
firstSpy();
|
50
|
-
|
51
|
-
result = matcher.compare(firstSpy, secondSpy);
|
52
|
-
expect(result.pass).toBe(false);
|
53
|
-
expect(result.message).toEqual('Expected spy first spy to have been called before spy second spy');
|
54
|
-
});
|
55
|
-
|
56
|
-
it("fails when the actual is called before and after the expected", function() {
|
57
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
|
58
|
-
firstSpy = new jasmineUnderTest.Env().createSpy('first spy'),
|
59
|
-
secondSpy = new jasmineUnderTest.Env().createSpy('second spy'),
|
60
|
-
result;
|
61
|
-
|
62
|
-
firstSpy();
|
63
|
-
secondSpy();
|
64
|
-
firstSpy();
|
65
|
-
|
66
|
-
result = matcher.compare(firstSpy, secondSpy);
|
67
|
-
expect(result.pass).toBe(false);
|
68
|
-
expect(result.message).toEqual('Expected latest call to spy first spy to have been called before first call to spy second spy (no interleaved calls)');
|
69
|
-
});
|
70
|
-
|
71
|
-
it("fails when the expected is called before and after the actual", function() {
|
72
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
|
73
|
-
firstSpy = new jasmineUnderTest.Env().createSpy('first spy'),
|
74
|
-
secondSpy = new jasmineUnderTest.Env().createSpy('second spy'),
|
75
|
-
result;
|
76
|
-
|
77
|
-
secondSpy();
|
78
|
-
firstSpy();
|
79
|
-
secondSpy();
|
80
|
-
|
81
|
-
result = matcher.compare(firstSpy, secondSpy);
|
82
|
-
expect(result.pass).toBe(false);
|
83
|
-
expect(result.message).toEqual('Expected first call to spy second spy to have been called after latest call to spy first spy (no interleaved calls)');
|
84
|
-
});
|
85
|
-
|
86
|
-
it("passes when the actual is called before the expected", function() {
|
87
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
|
88
|
-
firstSpy = new jasmineUnderTest.Env().createSpy('first spy'),
|
89
|
-
secondSpy = new jasmineUnderTest.Env().createSpy('second spy'),
|
90
|
-
result;
|
91
|
-
|
92
|
-
firstSpy();
|
93
|
-
secondSpy();
|
94
|
-
|
95
|
-
result = matcher.compare(firstSpy, secondSpy);
|
96
|
-
expect(result.pass).toBe(true);
|
97
|
-
expect(result.message).toEqual('Expected spy first spy to not have been called before spy second spy, but it was');
|
98
|
-
});
|
99
|
-
});
|
@@ -1,47 +0,0 @@
|
|
1
|
-
describe("toHaveBeenCalled", function() {
|
2
|
-
it("passes when the actual was called, with a custom .not fail message", function() {
|
3
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
|
4
|
-
calledSpy = new jasmineUnderTest.Env().createSpy('called-spy'),
|
5
|
-
result;
|
6
|
-
|
7
|
-
calledSpy();
|
8
|
-
|
9
|
-
result = matcher.compare(calledSpy);
|
10
|
-
expect(result.pass).toBe(true);
|
11
|
-
expect(result.message).toEqual("Expected spy called-spy not to have been called.");
|
12
|
-
});
|
13
|
-
|
14
|
-
it("fails when the actual was not called", function() {
|
15
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
|
16
|
-
uncalledSpy = new jasmineUnderTest.Env().createSpy('uncalled spy'),
|
17
|
-
result;
|
18
|
-
|
19
|
-
result = matcher.compare(uncalledSpy);
|
20
|
-
expect(result.pass).toBe(false);
|
21
|
-
});
|
22
|
-
|
23
|
-
it("throws an exception when the actual is not a spy", function() {
|
24
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
|
25
|
-
fn = function() {};
|
26
|
-
|
27
|
-
expect(function() { matcher.compare(fn) }).toThrowError(Error, /Expected a spy, but got Function./);
|
28
|
-
});
|
29
|
-
|
30
|
-
it("throws an exception when invoked with any arguments", function() {
|
31
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
|
32
|
-
spy = new jasmineUnderTest.Env().createSpy('sample spy');
|
33
|
-
|
34
|
-
expect(function() { matcher.compare(spy, 'foo') }).toThrowError(Error, /Does not take arguments, use toHaveBeenCalledWith/);
|
35
|
-
});
|
36
|
-
|
37
|
-
it("has a custom message on failure", function() {
|
38
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
|
39
|
-
spy = new jasmineUnderTest.Env().createSpy('sample-spy'),
|
40
|
-
result;
|
41
|
-
|
42
|
-
result = matcher.compare(spy);
|
43
|
-
|
44
|
-
expect(result.message).toEqual("Expected spy sample-spy to have been called.");
|
45
|
-
});
|
46
|
-
});
|
47
|
-
|
@@ -1,86 +0,0 @@
|
|
1
|
-
describe("toHaveBeenCalledTimes", function() {
|
2
|
-
it("passes when the actual 0 matches the expected 0 ", function () {
|
3
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
|
4
|
-
calledSpy = new jasmineUnderTest.Env().createSpy('called-spy'),
|
5
|
-
result;
|
6
|
-
result = matcher.compare(calledSpy, 0);
|
7
|
-
expect(result.pass).toBeTruthy();
|
8
|
-
});
|
9
|
-
it("passes when the actual matches the expected", function() {
|
10
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
|
11
|
-
calledSpy = new jasmineUnderTest.Env().createSpy('called-spy'),
|
12
|
-
result;
|
13
|
-
calledSpy();
|
14
|
-
|
15
|
-
result = matcher.compare(calledSpy, 1);
|
16
|
-
expect(result.pass).toBe(true);
|
17
|
-
});
|
18
|
-
|
19
|
-
it("fails when expected numbers is not supplied", function(){
|
20
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
|
21
|
-
spy = new jasmineUnderTest.Env().createSpy('spy'),
|
22
|
-
result;
|
23
|
-
|
24
|
-
spy();
|
25
|
-
expect(function() {
|
26
|
-
matcher.compare(spy);
|
27
|
-
}).toThrowError(/The expected times failed is a required argument and must be a number./);
|
28
|
-
});
|
29
|
-
|
30
|
-
it("fails when the actual was called less than the expected", function() {
|
31
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
|
32
|
-
uncalledSpy = new jasmineUnderTest.Env().createSpy('uncalled spy'),
|
33
|
-
result;
|
34
|
-
|
35
|
-
result = matcher.compare(uncalledSpy, 2);
|
36
|
-
expect(result.pass).toBe(false);
|
37
|
-
});
|
38
|
-
|
39
|
-
it("fails when the actual was called more than expected", function() {
|
40
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
|
41
|
-
uncalledSpy = new jasmineUnderTest.Env().createSpy('uncalled spy'),
|
42
|
-
result;
|
43
|
-
|
44
|
-
uncalledSpy();
|
45
|
-
uncalledSpy();
|
46
|
-
|
47
|
-
result = matcher.compare(uncalledSpy, 1);
|
48
|
-
expect(result.pass).toBe(false);
|
49
|
-
});
|
50
|
-
|
51
|
-
it("throws an exception when the actual is not a spy", function() {
|
52
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
|
53
|
-
fn = function() {};
|
54
|
-
|
55
|
-
expect(function() {
|
56
|
-
matcher.compare(fn);
|
57
|
-
}).toThrowError(/Expected a spy, but got Function./);
|
58
|
-
});
|
59
|
-
|
60
|
-
it("has a custom message on failure that tells it was called only once", function() {
|
61
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
|
62
|
-
spy = new jasmineUnderTest.Env().createSpy('sample-spy'),
|
63
|
-
result;
|
64
|
-
spy();
|
65
|
-
spy();
|
66
|
-
spy();
|
67
|
-
spy();
|
68
|
-
|
69
|
-
result = matcher.compare(spy, 1);
|
70
|
-
expect(result.message).toEqual('Expected spy sample-spy to have been called once. It was called ' + 4 + ' times.');
|
71
|
-
});
|
72
|
-
|
73
|
-
it("has a custom message on failure that tells how many times it was called", function() {
|
74
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
|
75
|
-
spy = new jasmineUnderTest.Env().createSpy('sample-spy'),
|
76
|
-
result;
|
77
|
-
spy();
|
78
|
-
spy();
|
79
|
-
spy();
|
80
|
-
spy();
|
81
|
-
|
82
|
-
result = matcher.compare(spy, 2);
|
83
|
-
expect(result.message).toEqual('Expected spy sample-spy to have been called 2 times. It was called ' + 4 + ' times.');
|
84
|
-
});
|
85
|
-
});
|
86
|
-
|
@@ -1,67 +0,0 @@
|
|
1
|
-
describe("toHaveBeenCalledWith", function() {
|
2
|
-
|
3
|
-
it("passes when the actual was called with matching parameters", function() {
|
4
|
-
var util = {
|
5
|
-
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
|
6
|
-
},
|
7
|
-
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(util),
|
8
|
-
calledSpy = new jasmineUnderTest.Env().createSpy('called-spy'),
|
9
|
-
result;
|
10
|
-
|
11
|
-
calledSpy('a', 'b');
|
12
|
-
result = matcher.compare(calledSpy, 'a', 'b');
|
13
|
-
|
14
|
-
expect(result.pass).toBe(true);
|
15
|
-
expect(result.message()).toEqual("Expected spy called-spy not to have been called with [ 'a', 'b' ] but it was.");
|
16
|
-
});
|
17
|
-
|
18
|
-
it("passes through the custom equality testers", function() {
|
19
|
-
var util = {
|
20
|
-
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
|
21
|
-
},
|
22
|
-
customEqualityTesters = [function() { return true; }],
|
23
|
-
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(util, customEqualityTesters),
|
24
|
-
calledSpy = new jasmineUnderTest.Env().createSpy('called-spy');
|
25
|
-
|
26
|
-
calledSpy('a', 'b');
|
27
|
-
matcher.compare(calledSpy, 'a', 'b');
|
28
|
-
|
29
|
-
expect(util.contains).toHaveBeenCalledWith([['a', 'b']], ['a', 'b'], customEqualityTesters);
|
30
|
-
});
|
31
|
-
|
32
|
-
it("fails when the actual was not called", function() {
|
33
|
-
var util = {
|
34
|
-
contains: jasmine.createSpy('delegated-contains').and.returnValue(false)
|
35
|
-
},
|
36
|
-
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(util),
|
37
|
-
uncalledSpy = new jasmineUnderTest.Env().createSpy('uncalled spy'),
|
38
|
-
result;
|
39
|
-
|
40
|
-
result = matcher.compare(uncalledSpy);
|
41
|
-
expect(result.pass).toBe(false);
|
42
|
-
expect(result.message()).toEqual("Expected spy uncalled spy to have been called with [ ] but it was never called.");
|
43
|
-
});
|
44
|
-
|
45
|
-
it("fails when the actual was called with different parameters", function() {
|
46
|
-
var util = {
|
47
|
-
contains: jasmine.createSpy('delegated-contains').and.returnValue(false)
|
48
|
-
},
|
49
|
-
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(util),
|
50
|
-
calledSpy = new jasmineUnderTest.Env().createSpy('called spy'),
|
51
|
-
result;
|
52
|
-
|
53
|
-
calledSpy('a');
|
54
|
-
calledSpy('c', 'd');
|
55
|
-
result = matcher.compare(calledSpy, 'a', 'b');
|
56
|
-
|
57
|
-
expect(result.pass).toBe(false);
|
58
|
-
expect(result.message()).toEqual("Expected spy called spy to have been called with [ 'a', 'b' ] but actual calls were [ 'a' ], [ 'c', 'd' ].");
|
59
|
-
});
|
60
|
-
|
61
|
-
it("throws an exception when the actual is not a spy", function() {
|
62
|
-
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(),
|
63
|
-
fn = function() {};
|
64
|
-
|
65
|
-
expect(function() { matcher.compare(fn) }).toThrowError(/Expected a spy, but got Function./);
|
66
|
-
});
|
67
|
-
});
|
@@ -1,43 +0,0 @@
|
|
1
|
-
describe("toMatch", function() {
|
2
|
-
|
3
|
-
it("passes when RegExps are equivalent", function() {
|
4
|
-
var matcher = jasmineUnderTest.matchers.toMatch(),
|
5
|
-
result;
|
6
|
-
|
7
|
-
result = matcher.compare(/foo/, /foo/);
|
8
|
-
expect(result.pass).toBe(true);
|
9
|
-
});
|
10
|
-
|
11
|
-
it("fails when RegExps are not equivalent", function() {
|
12
|
-
var matcher = jasmineUnderTest.matchers.toMatch(),
|
13
|
-
result;
|
14
|
-
|
15
|
-
result = matcher.compare(/bar/, /foo/);
|
16
|
-
expect(result.pass).toBe(false);
|
17
|
-
});
|
18
|
-
|
19
|
-
it("passes when the actual matches the expected string as a pattern", function() {
|
20
|
-
var matcher = jasmineUnderTest.matchers.toMatch(),
|
21
|
-
result;
|
22
|
-
|
23
|
-
result = matcher.compare('foosball', 'foo');
|
24
|
-
expect(result.pass).toBe(true);
|
25
|
-
});
|
26
|
-
|
27
|
-
it("fails when the actual matches the expected string as a pattern", function() {
|
28
|
-
var matcher = jasmineUnderTest.matchers.toMatch(),
|
29
|
-
result;
|
30
|
-
|
31
|
-
result = matcher.compare('bar', 'foo');
|
32
|
-
expect(result.pass).toBe(false);
|
33
|
-
});
|
34
|
-
|
35
|
-
it("throws an Error when the expected is not a String or RegExp", function() {
|
36
|
-
var matcher = jasmineUnderTest.matchers.toMatch();
|
37
|
-
|
38
|
-
expect(function() {
|
39
|
-
matcher.compare('foo', { bar: 'baz' });
|
40
|
-
}).toThrowError(/Expected is not a String or a RegExp/);
|
41
|
-
});
|
42
|
-
});
|
43
|
-
|
@@ -1,315 +0,0 @@
|
|
1
|
-
describe("toThrowError", function() {
|
2
|
-
it("throws an error when the actual is not a function", function() {
|
3
|
-
var matcher = jasmineUnderTest.matchers.toThrowError();
|
4
|
-
|
5
|
-
expect(function() {
|
6
|
-
matcher.compare({});
|
7
|
-
}).toThrowError(/Actual is not a Function/);
|
8
|
-
});
|
9
|
-
|
10
|
-
it("throws an error when the expected is not an Error, string, or RegExp", function() {
|
11
|
-
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
12
|
-
fn = function() {
|
13
|
-
throw new Error("foo");
|
14
|
-
};
|
15
|
-
|
16
|
-
expect(function() {
|
17
|
-
matcher.compare(fn, 1);
|
18
|
-
}).toThrowError(/Expected is not an Error, string, or RegExp./);
|
19
|
-
});
|
20
|
-
|
21
|
-
it("throws an error when the expected error type is not an Error", function() {
|
22
|
-
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
23
|
-
fn = function() {
|
24
|
-
throw new Error("foo");
|
25
|
-
};
|
26
|
-
|
27
|
-
expect(function() {
|
28
|
-
matcher.compare(fn, void 0, "foo");
|
29
|
-
}).toThrowError(/Expected error type is not an Error./);
|
30
|
-
});
|
31
|
-
|
32
|
-
it("throws an error when the expected error message is not a string or RegExp", function() {
|
33
|
-
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
34
|
-
fn = function() {
|
35
|
-
throw new Error("foo");
|
36
|
-
};
|
37
|
-
|
38
|
-
expect(function() {
|
39
|
-
matcher.compare(fn, Error, 1);
|
40
|
-
}).toThrowError(/Expected error message is not a string or RegExp./);
|
41
|
-
});
|
42
|
-
|
43
|
-
it("fails if actual does not throw at all", function() {
|
44
|
-
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
45
|
-
fn = function() {
|
46
|
-
return true;
|
47
|
-
},
|
48
|
-
result;
|
49
|
-
|
50
|
-
result = matcher.compare(fn);
|
51
|
-
|
52
|
-
expect(result.pass).toBe(false);
|
53
|
-
expect(result.message).toEqual("Expected function to throw an Error.");
|
54
|
-
});
|
55
|
-
|
56
|
-
it("fails if thrown is not an instanceof Error", function() {
|
57
|
-
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
58
|
-
fn = function() {
|
59
|
-
throw 4;
|
60
|
-
},
|
61
|
-
result;
|
62
|
-
|
63
|
-
result = matcher.compare(fn);
|
64
|
-
expect(result.pass).toBe(false);
|
65
|
-
expect(result.message()).toEqual("Expected function to throw an Error, but it threw 4.");
|
66
|
-
});
|
67
|
-
|
68
|
-
describe("when error is from another frame", function() {
|
69
|
-
function isNotRunningInBrowser() {
|
70
|
-
return typeof document === 'undefined'
|
71
|
-
}
|
72
|
-
|
73
|
-
var iframe = null;
|
74
|
-
|
75
|
-
afterEach(function() {
|
76
|
-
if (iframe !== null) {
|
77
|
-
document.body.removeChild(iframe);
|
78
|
-
}
|
79
|
-
});
|
80
|
-
|
81
|
-
it("passes if thrown is an instanceof Error regardless of global that contains its constructor", function() {
|
82
|
-
if (isNotRunningInBrowser()) {
|
83
|
-
return;
|
84
|
-
}
|
85
|
-
|
86
|
-
var matcher = jasmineUnderTest.matchers.toThrowError();
|
87
|
-
iframe = document.body.appendChild(document.createElement("iframe"));
|
88
|
-
iframe.src = "about:blank";
|
89
|
-
var iframeDocument = iframe.contentWindow.document;
|
90
|
-
|
91
|
-
if (iframeDocument.body) {
|
92
|
-
iframeDocument.body.appendChild(iframeDocument.createElement("script"))
|
93
|
-
.textContent = "function method() { throw new Error('foo'); }";
|
94
|
-
} else {
|
95
|
-
// IE 10 and older
|
96
|
-
iframeDocument.write("<html><head><script>function method() { throw new Error('foo'); }</script></head></html>");
|
97
|
-
}
|
98
|
-
|
99
|
-
var result = matcher.compare(iframe.contentWindow.method);
|
100
|
-
expect(result.pass).toBe(true);
|
101
|
-
expect(result.message).toEqual("Expected function not to throw an Error, but it threw Error.");
|
102
|
-
});
|
103
|
-
});
|
104
|
-
|
105
|
-
it("fails with the correct message if thrown is a falsy value", function() {
|
106
|
-
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
107
|
-
fn = function() {
|
108
|
-
throw undefined;
|
109
|
-
},
|
110
|
-
result;
|
111
|
-
|
112
|
-
result = matcher.compare(fn);
|
113
|
-
expect(result.pass).toBe(false);
|
114
|
-
expect(result.message()).toEqual("Expected function to throw an Error, but it threw undefined.");
|
115
|
-
});
|
116
|
-
|
117
|
-
it("passes if thrown is a type of Error, but there is no expected error", function() {
|
118
|
-
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
119
|
-
fn = function() {
|
120
|
-
throw new TypeError();
|
121
|
-
},
|
122
|
-
result;
|
123
|
-
|
124
|
-
result = matcher.compare(fn);
|
125
|
-
|
126
|
-
expect(result.pass).toBe(true);
|
127
|
-
expect(result.message).toEqual("Expected function not to throw an Error, but it threw TypeError.");
|
128
|
-
});
|
129
|
-
|
130
|
-
it("passes if thrown is an Error and the expected is the same message", function() {
|
131
|
-
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
132
|
-
fn = function() {
|
133
|
-
throw new Error("foo");
|
134
|
-
},
|
135
|
-
result;
|
136
|
-
|
137
|
-
result = matcher.compare(fn, "foo");
|
138
|
-
|
139
|
-
expect(result.pass).toBe(true);
|
140
|
-
expect(result.message()).toEqual("Expected function not to throw an exception with message 'foo'.");
|
141
|
-
});
|
142
|
-
|
143
|
-
it("fails if thrown is an Error and the expected is not the same message", function() {
|
144
|
-
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
145
|
-
fn = function() {
|
146
|
-
throw new Error("foo");
|
147
|
-
},
|
148
|
-
result;
|
149
|
-
|
150
|
-
result = matcher.compare(fn, "bar");
|
151
|
-
|
152
|
-
expect(result.pass).toBe(false);
|
153
|
-
expect(result.message()).toEqual("Expected function to throw an exception with message 'bar', but it threw an exception with message 'foo'.");
|
154
|
-
});
|
155
|
-
|
156
|
-
it("passes if thrown is an Error and the expected is a RegExp that matches the message", function() {
|
157
|
-
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
158
|
-
fn = function() {
|
159
|
-
throw new Error("a long message");
|
160
|
-
},
|
161
|
-
result;
|
162
|
-
|
163
|
-
result = matcher.compare(fn, /long/);
|
164
|
-
|
165
|
-
expect(result.pass).toBe(true);
|
166
|
-
expect(result.message()).toEqual("Expected function not to throw an exception with a message matching /long/.");
|
167
|
-
});
|
168
|
-
|
169
|
-
it("fails if thrown is an Error and the expected is a RegExp that does not match the message", function() {
|
170
|
-
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
171
|
-
fn = function() {
|
172
|
-
throw new Error("a long message");
|
173
|
-
},
|
174
|
-
result;
|
175
|
-
|
176
|
-
result = matcher.compare(fn, /foo/);
|
177
|
-
|
178
|
-
expect(result.pass).toBe(false);
|
179
|
-
expect(result.message()).toEqual("Expected function to throw an exception with a message matching /foo/, but it threw an exception with message 'a long message'.");
|
180
|
-
});
|
181
|
-
|
182
|
-
it("passes if thrown is an Error and the expected the same Error", function() {
|
183
|
-
var util = {
|
184
|
-
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
185
|
-
},
|
186
|
-
matcher = jasmineUnderTest.matchers.toThrowError(),
|
187
|
-
fn = function() {
|
188
|
-
throw new Error();
|
189
|
-
},
|
190
|
-
result;
|
191
|
-
|
192
|
-
result = matcher.compare(fn, Error);
|
193
|
-
|
194
|
-
expect(result.pass).toBe(true);
|
195
|
-
expect(result.message()).toEqual("Expected function not to throw Error.");
|
196
|
-
});
|
197
|
-
|
198
|
-
it("passes if thrown is a custom error that takes arguments and the expected is the same error", function() {
|
199
|
-
var util = {
|
200
|
-
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
201
|
-
},
|
202
|
-
matcher = jasmineUnderTest.matchers.toThrowError(),
|
203
|
-
CustomError = function CustomError(arg) { arg.x },
|
204
|
-
fn = function() {
|
205
|
-
throw new CustomError({ x: 1 });
|
206
|
-
},
|
207
|
-
result;
|
208
|
-
|
209
|
-
CustomError.prototype = new Error();
|
210
|
-
|
211
|
-
result = matcher.compare(fn, CustomError);
|
212
|
-
|
213
|
-
expect(result.pass).toBe(true);
|
214
|
-
expect(result.message()).toEqual("Expected function not to throw CustomError.");
|
215
|
-
});
|
216
|
-
|
217
|
-
it("fails if thrown is an Error and the expected is a different Error", function() {
|
218
|
-
var util = {
|
219
|
-
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
|
220
|
-
},
|
221
|
-
matcher = jasmineUnderTest.matchers.toThrowError(),
|
222
|
-
fn = function() {
|
223
|
-
throw new Error();
|
224
|
-
},
|
225
|
-
result;
|
226
|
-
|
227
|
-
result = matcher.compare(fn, TypeError);
|
228
|
-
|
229
|
-
expect(result.pass).toBe(false);
|
230
|
-
expect(result.message()).toEqual("Expected function to throw TypeError, but it threw Error.");
|
231
|
-
});
|
232
|
-
|
233
|
-
it("passes if thrown is a type of Error and it is equal to the expected Error and message", function() {
|
234
|
-
var util = {
|
235
|
-
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
236
|
-
},
|
237
|
-
matcher = jasmineUnderTest.matchers.toThrowError(),
|
238
|
-
fn = function() {
|
239
|
-
throw new TypeError("foo");
|
240
|
-
},
|
241
|
-
result;
|
242
|
-
|
243
|
-
result = matcher.compare(fn, TypeError, "foo");
|
244
|
-
|
245
|
-
expect(result.pass).toBe(true);
|
246
|
-
expect(result.message()).toEqual("Expected function not to throw TypeError with message 'foo'.");
|
247
|
-
});
|
248
|
-
|
249
|
-
it("passes if thrown is a custom error that takes arguments and it is equal to the expected custom error and message", function() {
|
250
|
-
var util = {
|
251
|
-
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
252
|
-
},
|
253
|
-
matcher = jasmineUnderTest.matchers.toThrowError(),
|
254
|
-
CustomError = function CustomError(arg) { this.message = arg.message },
|
255
|
-
fn = function() {
|
256
|
-
throw new CustomError({message: "foo"});
|
257
|
-
},
|
258
|
-
result;
|
259
|
-
|
260
|
-
CustomError.prototype = new Error();
|
261
|
-
|
262
|
-
result = matcher.compare(fn, CustomError, "foo");
|
263
|
-
|
264
|
-
expect(result.pass).toBe(true);
|
265
|
-
expect(result.message()).toEqual("Expected function not to throw CustomError with message 'foo'.");
|
266
|
-
});
|
267
|
-
|
268
|
-
it("fails if thrown is a type of Error and the expected is a different Error", function() {
|
269
|
-
var util = {
|
270
|
-
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
|
271
|
-
},
|
272
|
-
matcher = jasmineUnderTest.matchers.toThrowError(),
|
273
|
-
fn = function() {
|
274
|
-
throw new TypeError("foo");
|
275
|
-
},
|
276
|
-
result;
|
277
|
-
|
278
|
-
result = matcher.compare(fn, TypeError, "bar");
|
279
|
-
|
280
|
-
expect(result.pass).toBe(false);
|
281
|
-
expect(result.message()).toEqual("Expected function to throw TypeError with message 'bar', but it threw TypeError with message 'foo'.");
|
282
|
-
});
|
283
|
-
|
284
|
-
it("passes if thrown is a type of Error and has the same type as the expected Error and the message matches the expected message", function() {
|
285
|
-
var util = {
|
286
|
-
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
287
|
-
},
|
288
|
-
matcher = jasmineUnderTest.matchers.toThrowError(),
|
289
|
-
fn = function() {
|
290
|
-
throw new TypeError("foo");
|
291
|
-
},
|
292
|
-
result;
|
293
|
-
|
294
|
-
result = matcher.compare(fn, TypeError, /foo/);
|
295
|
-
|
296
|
-
expect(result.pass).toBe(true);
|
297
|
-
expect(result.message()).toEqual("Expected function not to throw TypeError with a message matching /foo/.");
|
298
|
-
});
|
299
|
-
|
300
|
-
it("fails if thrown is a type of Error and the expected is a different Error", function() {
|
301
|
-
var util = {
|
302
|
-
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
|
303
|
-
},
|
304
|
-
matcher = jasmineUnderTest.matchers.toThrowError(),
|
305
|
-
fn = function() {
|
306
|
-
throw new TypeError("foo");
|
307
|
-
},
|
308
|
-
result;
|
309
|
-
|
310
|
-
result = matcher.compare(fn, TypeError, /bar/);
|
311
|
-
|
312
|
-
expect(result.pass).toBe(false);
|
313
|
-
expect(result.message()).toEqual("Expected function to throw TypeError with a message matching /bar/, but it threw TypeError with message 'foo'.");
|
314
|
-
});
|
315
|
-
});
|