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,202 @@
|
|
1
|
+
describe("SpyStrategy", function() {
|
2
|
+
|
3
|
+
it("defaults its name to unknown", function() {
|
4
|
+
var spyStrategy = new jasmineUnderTest.SpyStrategy();
|
5
|
+
|
6
|
+
expect(spyStrategy.identity).toEqual("unknown");
|
7
|
+
});
|
8
|
+
|
9
|
+
it("takes a name", function() {
|
10
|
+
var spyStrategy = new jasmineUnderTest.SpyStrategy({name: "foo"});
|
11
|
+
|
12
|
+
expect(spyStrategy.identity).toEqual("foo");
|
13
|
+
});
|
14
|
+
|
15
|
+
it("stubs an original function, if provided", function() {
|
16
|
+
var originalFn = jasmine.createSpy("original"),
|
17
|
+
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn});
|
18
|
+
|
19
|
+
spyStrategy.exec();
|
20
|
+
|
21
|
+
expect(originalFn).not.toHaveBeenCalled();
|
22
|
+
});
|
23
|
+
|
24
|
+
it("allows an original function to be called, passed through the params and returns it's value", function() {
|
25
|
+
var originalFn = jasmine.createSpy("original").and.returnValue(42),
|
26
|
+
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn}),
|
27
|
+
returnValue;
|
28
|
+
|
29
|
+
spyStrategy.callThrough();
|
30
|
+
returnValue = spyStrategy.exec(null, ["foo"]);
|
31
|
+
|
32
|
+
expect(originalFn).toHaveBeenCalled();
|
33
|
+
expect(originalFn.calls.mostRecent().args).toEqual(["foo"]);
|
34
|
+
expect(returnValue).toEqual(42);
|
35
|
+
});
|
36
|
+
|
37
|
+
it("can return a specified value when executed", function() {
|
38
|
+
var originalFn = jasmine.createSpy("original"),
|
39
|
+
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn}),
|
40
|
+
returnValue;
|
41
|
+
|
42
|
+
spyStrategy.returnValue(17);
|
43
|
+
returnValue = spyStrategy.exec();
|
44
|
+
|
45
|
+
expect(originalFn).not.toHaveBeenCalled();
|
46
|
+
expect(returnValue).toEqual(17);
|
47
|
+
});
|
48
|
+
|
49
|
+
it("can return specified values in order specified when executed", function() {
|
50
|
+
var originalFn = jasmine.createSpy("original"),
|
51
|
+
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn});
|
52
|
+
|
53
|
+
spyStrategy.returnValues('value1', 'value2', 'value3');
|
54
|
+
|
55
|
+
expect(spyStrategy.exec()).toEqual('value1');
|
56
|
+
expect(spyStrategy.exec()).toEqual('value2');
|
57
|
+
expect(spyStrategy.exec()).toBe('value3');
|
58
|
+
expect(spyStrategy.exec()).toBeUndefined();
|
59
|
+
expect(originalFn).not.toHaveBeenCalled();
|
60
|
+
});
|
61
|
+
|
62
|
+
it("allows an exception to be thrown when executed", function() {
|
63
|
+
var originalFn = jasmine.createSpy("original"),
|
64
|
+
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn});
|
65
|
+
|
66
|
+
spyStrategy.throwError(new TypeError("bar"));
|
67
|
+
|
68
|
+
expect(function() { spyStrategy.exec(); }).toThrowError(TypeError, "bar");
|
69
|
+
expect(originalFn).not.toHaveBeenCalled();
|
70
|
+
});
|
71
|
+
|
72
|
+
it("allows a non-Error to be thrown, wrapping it into an exception when executed", function() {
|
73
|
+
var originalFn = jasmine.createSpy("original"),
|
74
|
+
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn});
|
75
|
+
|
76
|
+
spyStrategy.throwError("bar");
|
77
|
+
|
78
|
+
expect(function() { spyStrategy.exec(); }).toThrowError(Error, "bar");
|
79
|
+
expect(originalFn).not.toHaveBeenCalled();
|
80
|
+
});
|
81
|
+
|
82
|
+
it("allows a fake function to be called instead", function() {
|
83
|
+
var originalFn = jasmine.createSpy("original"),
|
84
|
+
fakeFn = jasmine.createSpy("fake").and.returnValue(67),
|
85
|
+
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn}),
|
86
|
+
returnValue;
|
87
|
+
|
88
|
+
spyStrategy.callFake(fakeFn);
|
89
|
+
returnValue = spyStrategy.exec();
|
90
|
+
|
91
|
+
expect(originalFn).not.toHaveBeenCalled();
|
92
|
+
expect(returnValue).toEqual(67);
|
93
|
+
});
|
94
|
+
|
95
|
+
it("allows a fake async function to be called instead", function(done) {
|
96
|
+
jasmine.getEnv().requireAsyncAwait();
|
97
|
+
var originalFn = jasmine.createSpy("original"),
|
98
|
+
fakeFn = jasmine.createSpy("fake").and.callFake(eval("async () => { return 67; }")),
|
99
|
+
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn}),
|
100
|
+
returnValue;
|
101
|
+
|
102
|
+
spyStrategy.callFake(fakeFn);
|
103
|
+
spyStrategy.exec().then(function (returnValue) {
|
104
|
+
expect(originalFn).not.toHaveBeenCalled();
|
105
|
+
expect(fakeFn).toHaveBeenCalled();
|
106
|
+
expect(returnValue).toEqual(67);
|
107
|
+
done();
|
108
|
+
}).catch(function (err) {
|
109
|
+
done.fail(err);
|
110
|
+
})
|
111
|
+
});
|
112
|
+
|
113
|
+
it("allows a custom strategy to be used", function() {
|
114
|
+
var plan = jasmine.createSpy('custom strategy')
|
115
|
+
.and.returnValue('custom strategy result'),
|
116
|
+
customStrategy = jasmine.createSpy('custom strategy')
|
117
|
+
.and.returnValue(plan),
|
118
|
+
originalFn = jasmine.createSpy('original'),
|
119
|
+
spyStrategy = new jasmineUnderTest.SpyStrategy({
|
120
|
+
fn: originalFn,
|
121
|
+
customStrategies: {
|
122
|
+
doSomething: customStrategy
|
123
|
+
}
|
124
|
+
});
|
125
|
+
|
126
|
+
spyStrategy.doSomething(1, 2, 3);
|
127
|
+
expect(customStrategy).toHaveBeenCalledWith(1, 2, 3);
|
128
|
+
expect(spyStrategy.exec(null, ['some', 'args']))
|
129
|
+
.toEqual('custom strategy result');
|
130
|
+
expect(plan).toHaveBeenCalledWith('some', 'args');
|
131
|
+
});
|
132
|
+
|
133
|
+
it("throws an error if a custom strategy doesn't return a function", function() {
|
134
|
+
var originalFn = jasmine.createSpy('original'),
|
135
|
+
spyStrategy = new jasmineUnderTest.SpyStrategy({
|
136
|
+
fn: originalFn,
|
137
|
+
customStrategies: {
|
138
|
+
doSomething: function() { return 'not a function' }
|
139
|
+
}
|
140
|
+
});
|
141
|
+
|
142
|
+
expect(function() { spyStrategy.doSomething(1, 2, 3) }).toThrowError('Spy strategy must return a function');
|
143
|
+
});
|
144
|
+
|
145
|
+
it("does not allow custom strategies to overwrite existing methods", function() {
|
146
|
+
var spyStrategy = new jasmineUnderTest.SpyStrategy({
|
147
|
+
fn: function() {},
|
148
|
+
customStrategies: {
|
149
|
+
exec: function() {}
|
150
|
+
}
|
151
|
+
});
|
152
|
+
|
153
|
+
expect(spyStrategy.exec).toBe(jasmineUnderTest.SpyStrategy.prototype.exec);
|
154
|
+
});
|
155
|
+
|
156
|
+
it('throws an error when a non-function is passed to callFake strategy', function() {
|
157
|
+
var originalFn = jasmine.createSpy('original'),
|
158
|
+
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn}),
|
159
|
+
invalidFakes = [5, 'foo', {}, true, false, null, void 0, new Date(), /.*/];
|
160
|
+
|
161
|
+
spyOn(jasmineUnderTest, 'isFunction_').and.returnValue(false);
|
162
|
+
spyOn(jasmineUnderTest, 'isAsyncFunction_').and.returnValue(false);
|
163
|
+
|
164
|
+
expect(function () {
|
165
|
+
spyStrategy.callFake(function() {});
|
166
|
+
}).toThrowError(/^Argument passed to callFake should be a function, got/);
|
167
|
+
|
168
|
+
expect(function () {
|
169
|
+
spyStrategy.callFake(function() {});
|
170
|
+
}).toThrowError(/^Argument passed to callFake should be a function, got/);
|
171
|
+
});
|
172
|
+
|
173
|
+
it("allows a return to plan stubbing after another strategy", function() {
|
174
|
+
var originalFn = jasmine.createSpy("original"),
|
175
|
+
fakeFn = jasmine.createSpy("fake").and.returnValue(67),
|
176
|
+
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn}),
|
177
|
+
returnValue;
|
178
|
+
|
179
|
+
spyStrategy.callFake(fakeFn);
|
180
|
+
returnValue = spyStrategy.exec();
|
181
|
+
|
182
|
+
expect(originalFn).not.toHaveBeenCalled();
|
183
|
+
expect(returnValue).toEqual(67);
|
184
|
+
|
185
|
+
spyStrategy.stub();
|
186
|
+
returnValue = spyStrategy.exec();
|
187
|
+
|
188
|
+
expect(returnValue).toEqual(void 0);
|
189
|
+
});
|
190
|
+
|
191
|
+
it("returns the spy after changing the strategy", function(){
|
192
|
+
var spy = {},
|
193
|
+
spyFn = jasmine.createSpy('spyFn').and.returnValue(spy),
|
194
|
+
spyStrategy = new jasmineUnderTest.SpyStrategy({getSpy: spyFn});
|
195
|
+
|
196
|
+
expect(spyStrategy.callThrough()).toBe(spy);
|
197
|
+
expect(spyStrategy.returnValue()).toBe(spy);
|
198
|
+
expect(spyStrategy.throwError()).toBe(spy);
|
199
|
+
expect(spyStrategy.callFake(function() {})).toBe(spy);
|
200
|
+
expect(spyStrategy.stub()).toBe(spy);
|
201
|
+
});
|
202
|
+
});
|
@@ -0,0 +1,166 @@
|
|
1
|
+
describe("StackTrace", function() {
|
2
|
+
it("understands Chrome/IE/Edge style traces", function() {
|
3
|
+
var raw =
|
4
|
+
'Error: nope\n' +
|
5
|
+
' at UserContext.<anonymous> (http://localhost:8888/__spec__/core/UtilSpec.js:115:19)\n' +
|
6
|
+
' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)';
|
7
|
+
|
8
|
+
var result = new jasmineUnderTest.StackTrace(raw);
|
9
|
+
|
10
|
+
expect(result.message).toEqual('Error: nope');
|
11
|
+
expect(result.style).toEqual('v8');
|
12
|
+
expect(result.frames).toEqual([
|
13
|
+
{
|
14
|
+
raw: ' at UserContext.<anonymous> (http://localhost:8888/__spec__/core/UtilSpec.js:115:19)',
|
15
|
+
func: 'UserContext.<anonymous>',
|
16
|
+
file: 'http://localhost:8888/__spec__/core/UtilSpec.js',
|
17
|
+
line: 115
|
18
|
+
},
|
19
|
+
{
|
20
|
+
raw: ' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)',
|
21
|
+
func: 'QueueRunner.run',
|
22
|
+
file: 'http://localhost:8888/__jasmine__/jasmine.js',
|
23
|
+
line: 4320
|
24
|
+
}
|
25
|
+
]);
|
26
|
+
});
|
27
|
+
|
28
|
+
it("understands Node style traces", function() {
|
29
|
+
var raw = 'Error\n' +
|
30
|
+
' at /somewhere/jasmine/lib/jasmine-core/jasmine.js:4255:9\n' +
|
31
|
+
' at QueueRunner.complete [as onComplete] (/somewhere/jasmine/lib/jasmine-core/jasmine.js:579:9)\n' +
|
32
|
+
' at Immediate.<anonymous> (/somewhere/jasmine/lib/jasmine-core/jasmine.js:4314:12)\n' +
|
33
|
+
' at runCallback (timers.js:672:20)';
|
34
|
+
var result = new jasmineUnderTest.StackTrace(raw);
|
35
|
+
|
36
|
+
expect(result.message).toEqual('Error');
|
37
|
+
expect(result.style).toEqual('v8');
|
38
|
+
expect(result.frames).toEqual([
|
39
|
+
{
|
40
|
+
raw: ' at /somewhere/jasmine/lib/jasmine-core/jasmine.js:4255:9',
|
41
|
+
func: undefined,
|
42
|
+
file: '/somewhere/jasmine/lib/jasmine-core/jasmine.js',
|
43
|
+
line: 4255
|
44
|
+
},
|
45
|
+
{
|
46
|
+
raw: ' at QueueRunner.complete [as onComplete] (/somewhere/jasmine/lib/jasmine-core/jasmine.js:579:9)',
|
47
|
+
func: 'QueueRunner.complete [as onComplete]',
|
48
|
+
file: '/somewhere/jasmine/lib/jasmine-core/jasmine.js',
|
49
|
+
line: 579
|
50
|
+
},
|
51
|
+
{
|
52
|
+
raw: ' at Immediate.<anonymous> (/somewhere/jasmine/lib/jasmine-core/jasmine.js:4314:12)',
|
53
|
+
func: 'Immediate.<anonymous>',
|
54
|
+
file: '/somewhere/jasmine/lib/jasmine-core/jasmine.js',
|
55
|
+
line: 4314
|
56
|
+
},
|
57
|
+
{
|
58
|
+
raw: ' at runCallback (timers.js:672:20)',
|
59
|
+
func: 'runCallback',
|
60
|
+
file: 'timers.js',
|
61
|
+
line: 672
|
62
|
+
}
|
63
|
+
]);
|
64
|
+
});
|
65
|
+
|
66
|
+
it("understands Safari/Firefox/Phantom-OS X style traces", function() {
|
67
|
+
var raw =
|
68
|
+
'http://localhost:8888/__spec__/core/UtilSpec.js:115:28\n' +
|
69
|
+
'run@http://localhost:8888/__jasmine__/jasmine.js:4320:27';
|
70
|
+
var result = new jasmineUnderTest.StackTrace(raw);
|
71
|
+
|
72
|
+
expect(result.message).toBeFalsy();
|
73
|
+
expect(result.style).toEqual('webkit');
|
74
|
+
expect(result.frames).toEqual([
|
75
|
+
{
|
76
|
+
raw: 'http://localhost:8888/__spec__/core/UtilSpec.js:115:28',
|
77
|
+
func: undefined,
|
78
|
+
file: 'http://localhost:8888/__spec__/core/UtilSpec.js',
|
79
|
+
line: 115
|
80
|
+
},
|
81
|
+
{
|
82
|
+
raw: 'run@http://localhost:8888/__jasmine__/jasmine.js:4320:27',
|
83
|
+
func: 'run',
|
84
|
+
file: 'http://localhost:8888/__jasmine__/jasmine.js',
|
85
|
+
line: 4320
|
86
|
+
}
|
87
|
+
]);
|
88
|
+
});
|
89
|
+
|
90
|
+
it("does not mistake gibberish for Safari/Firefox/Phantom-OS X style traces", function() {
|
91
|
+
var raw = 'randomcharsnotincludingwhitespace';
|
92
|
+
var result = new jasmineUnderTest.StackTrace(raw);
|
93
|
+
expect(result.style).toBeNull();
|
94
|
+
expect(result.frames).toEqual([
|
95
|
+
{ raw: raw }
|
96
|
+
]);
|
97
|
+
});
|
98
|
+
|
99
|
+
it("understands Phantom-Linux style traces", function() {
|
100
|
+
var raw =
|
101
|
+
' at UserContext.<anonymous> (http://localhost:8888/__spec__/core/UtilSpec.js:115:19)\n' +
|
102
|
+
' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)';
|
103
|
+
|
104
|
+
var result = new jasmineUnderTest.StackTrace(raw);
|
105
|
+
|
106
|
+
expect(result.message).toBeFalsy();
|
107
|
+
expect(result.style).toEqual('v8');
|
108
|
+
expect(result.frames).toEqual([
|
109
|
+
{
|
110
|
+
raw: ' at UserContext.<anonymous> (http://localhost:8888/__spec__/core/UtilSpec.js:115:19)',
|
111
|
+
func: 'UserContext.<anonymous>',
|
112
|
+
file: 'http://localhost:8888/__spec__/core/UtilSpec.js',
|
113
|
+
line: 115
|
114
|
+
},
|
115
|
+
{
|
116
|
+
raw: ' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)',
|
117
|
+
func: 'QueueRunner.run',
|
118
|
+
file: 'http://localhost:8888/__jasmine__/jasmine.js',
|
119
|
+
line: 4320
|
120
|
+
}
|
121
|
+
]);
|
122
|
+
});
|
123
|
+
|
124
|
+
it("ignores blank lines", function() {
|
125
|
+
var raw =
|
126
|
+
' at UserContext.<anonymous> (http://localhost:8888/__spec__/core/UtilSpec.js:115:19)\n';
|
127
|
+
|
128
|
+
var result = new jasmineUnderTest.StackTrace(raw);
|
129
|
+
|
130
|
+
expect(result.frames).toEqual([
|
131
|
+
{
|
132
|
+
raw: ' at UserContext.<anonymous> (http://localhost:8888/__spec__/core/UtilSpec.js:115:19)',
|
133
|
+
func: 'UserContext.<anonymous>',
|
134
|
+
file: 'http://localhost:8888/__spec__/core/UtilSpec.js',
|
135
|
+
line: 115
|
136
|
+
}
|
137
|
+
]);
|
138
|
+
});
|
139
|
+
|
140
|
+
it("omits properties except 'raw' for frames that are not understood", function() {
|
141
|
+
var raw =
|
142
|
+
' at UserContext.<anonymous> (http://localhost:8888/__spec__/core/UtilSpec.js:115:19)\n' +
|
143
|
+
' but this is quite unexpected\n' +
|
144
|
+
' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)';
|
145
|
+
|
146
|
+
var result = new jasmineUnderTest.StackTrace(raw);
|
147
|
+
expect(result.style).toEqual('v8');
|
148
|
+
expect(result.frames).toEqual([
|
149
|
+
{
|
150
|
+
raw: ' at UserContext.<anonymous> (http://localhost:8888/__spec__/core/UtilSpec.js:115:19)',
|
151
|
+
func: 'UserContext.<anonymous>',
|
152
|
+
file: 'http://localhost:8888/__spec__/core/UtilSpec.js',
|
153
|
+
line: 115
|
154
|
+
},
|
155
|
+
{
|
156
|
+
raw: ' but this is quite unexpected'
|
157
|
+
},
|
158
|
+
{
|
159
|
+
raw: ' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)',
|
160
|
+
func: 'QueueRunner.run',
|
161
|
+
file: 'http://localhost:8888/__jasmine__/jasmine.js',
|
162
|
+
line: 4320
|
163
|
+
}
|
164
|
+
]);
|
165
|
+
});
|
166
|
+
});
|
@@ -0,0 +1,123 @@
|
|
1
|
+
describe("Suite", function() {
|
2
|
+
|
3
|
+
it("keeps its id", function() {
|
4
|
+
var env = new jasmineUnderTest.Env(),
|
5
|
+
suite = new jasmineUnderTest.Suite({
|
6
|
+
env: env,
|
7
|
+
id: 456,
|
8
|
+
description: "I am a suite"
|
9
|
+
});
|
10
|
+
|
11
|
+
expect(suite.id).toEqual(456);
|
12
|
+
});
|
13
|
+
|
14
|
+
it("returns blank full name for top level suite", function() {
|
15
|
+
var env = new jasmineUnderTest.Env(),
|
16
|
+
suite = new jasmineUnderTest.Suite({
|
17
|
+
env: env,
|
18
|
+
description: "I am a suite"
|
19
|
+
});
|
20
|
+
|
21
|
+
expect(suite.getFullName()).toEqual("");
|
22
|
+
});
|
23
|
+
|
24
|
+
it("returns its full name when it has parent suites", function() {
|
25
|
+
var env = new jasmineUnderTest.Env(),
|
26
|
+
parentSuite = new jasmineUnderTest.Suite({
|
27
|
+
env: env,
|
28
|
+
description: "I am a parent suite",
|
29
|
+
parentSuite: jasmine.createSpy('pretend top level suite')
|
30
|
+
}),
|
31
|
+
suite = new jasmineUnderTest.Suite({
|
32
|
+
env: env,
|
33
|
+
description: "I am a suite",
|
34
|
+
parentSuite: parentSuite
|
35
|
+
});
|
36
|
+
|
37
|
+
expect(suite.getFullName()).toEqual("I am a parent suite I am a suite");
|
38
|
+
});
|
39
|
+
|
40
|
+
it("adds before functions in order of needed execution", function() {
|
41
|
+
var env = new jasmineUnderTest.Env(),
|
42
|
+
suite = new jasmineUnderTest.Suite({
|
43
|
+
env: env,
|
44
|
+
description: "I am a suite"
|
45
|
+
}),
|
46
|
+
outerBefore = jasmine.createSpy('outerBeforeEach'),
|
47
|
+
innerBefore = jasmine.createSpy('insideBeforeEach');
|
48
|
+
|
49
|
+
suite.beforeEach(outerBefore);
|
50
|
+
suite.beforeEach(innerBefore);
|
51
|
+
|
52
|
+
expect(suite.beforeFns).toEqual([innerBefore, outerBefore]);
|
53
|
+
});
|
54
|
+
|
55
|
+
it("adds after functions in order of needed execution", function() {
|
56
|
+
var env = new jasmineUnderTest.Env(),
|
57
|
+
suite = new jasmineUnderTest.Suite({
|
58
|
+
env: env,
|
59
|
+
description: "I am a suite"
|
60
|
+
}),
|
61
|
+
outerAfter = jasmine.createSpy('outerAfterEach'),
|
62
|
+
innerAfter = jasmine.createSpy('insideAfterEach');
|
63
|
+
|
64
|
+
suite.afterEach(outerAfter);
|
65
|
+
suite.afterEach(innerAfter);
|
66
|
+
|
67
|
+
expect(suite.afterFns).toEqual([innerAfter, outerAfter]);
|
68
|
+
});
|
69
|
+
|
70
|
+
it('has a status of failed if any expectations have failed', function() {
|
71
|
+
var suite = new jasmineUnderTest.Suite({
|
72
|
+
expectationResultFactory: function() { return 'hi'; }
|
73
|
+
});
|
74
|
+
|
75
|
+
suite.addExpectationResult(false);
|
76
|
+
expect(suite.status()).toBe('failed');
|
77
|
+
});
|
78
|
+
|
79
|
+
it("retrieves a result with updated status", function() {
|
80
|
+
var suite = new jasmineUnderTest.Suite({});
|
81
|
+
|
82
|
+
expect(suite.getResult().status).toBe('passed');
|
83
|
+
});
|
84
|
+
|
85
|
+
it("retrieves a result with pending status", function() {
|
86
|
+
var suite = new jasmineUnderTest.Suite({});
|
87
|
+
suite.pend();
|
88
|
+
|
89
|
+
expect(suite.getResult().status).toBe('pending');
|
90
|
+
});
|
91
|
+
|
92
|
+
it("throws an ExpectationFailed when receiving a failed expectation when throwOnExpectationFailure is set", function() {
|
93
|
+
var suite = new jasmineUnderTest.Suite({
|
94
|
+
expectationResultFactory: function(data) { return data; },
|
95
|
+
throwOnExpectationFailure: true
|
96
|
+
});
|
97
|
+
|
98
|
+
expect(function() {
|
99
|
+
suite.addExpectationResult(false, 'failed');
|
100
|
+
}).toThrowError(jasmineUnderTest.errors.ExpectationFailed);
|
101
|
+
|
102
|
+
expect(suite.status()).toBe('failed');
|
103
|
+
expect(suite.result.failedExpectations).toEqual(['failed']);
|
104
|
+
});
|
105
|
+
|
106
|
+
it("does not add an additional failure when an expectation fails", function(){
|
107
|
+
var suite = new jasmineUnderTest.Suite({});
|
108
|
+
|
109
|
+
suite.onException(new jasmineUnderTest.errors.ExpectationFailed());
|
110
|
+
|
111
|
+
expect(suite.getResult().failedExpectations).toEqual([]);
|
112
|
+
});
|
113
|
+
|
114
|
+
describe('#sharedUserContext', function() {
|
115
|
+
beforeEach(function() {
|
116
|
+
this.suite = new jasmineUnderTest.Suite({});
|
117
|
+
});
|
118
|
+
|
119
|
+
it('returns a UserContext', function() {
|
120
|
+
expect(this.suite.sharedUserContext().constructor).toBe(jasmineUnderTest.UserContext);
|
121
|
+
});
|
122
|
+
});
|
123
|
+
});
|