jasmine-core 2.4.1 → 2.5.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/console/console.js +1 -1
- data/lib/jasmine-core/boot.js +1 -1
- data/lib/jasmine-core/jasmine-html.js +15 -7
- data/lib/jasmine-core/jasmine.js +261 -82
- data/lib/jasmine-core/node_boot.js +1 -1
- data/lib/jasmine-core/spec/console/ConsoleReporterSpec.js +16 -16
- data/lib/jasmine-core/spec/core/CallTrackerSpec.js +26 -11
- data/lib/jasmine-core/spec/core/ClockSpec.js +61 -42
- data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +28 -15
- data/lib/jasmine-core/spec/core/EnvSpec.js +8 -8
- data/lib/jasmine-core/spec/core/ExceptionFormatterSpec.js +6 -6
- data/lib/jasmine-core/spec/core/ExceptionsSpec.js +1 -1
- data/lib/jasmine-core/spec/core/ExpectationResultSpec.js +8 -8
- data/lib/jasmine-core/spec/core/ExpectationSpec.js +17 -17
- data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +14 -14
- data/lib/jasmine-core/spec/core/MockDateSpec.js +14 -14
- data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +65 -56
- data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +32 -18
- data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +27 -3
- data/lib/jasmine-core/spec/core/SpecSpec.js +37 -37
- data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +46 -7
- data/lib/jasmine-core/spec/core/SpySpec.js +11 -11
- data/lib/jasmine-core/spec/core/SpyStrategySpec.js +25 -13
- data/lib/jasmine-core/spec/core/SuiteSpec.js +25 -25
- data/lib/jasmine-core/spec/core/TimerSpec.js +2 -2
- data/lib/jasmine-core/spec/core/TreeProcessorSpec.js +26 -26
- data/lib/jasmine-core/spec/core/UtilSpec.js +12 -12
- data/lib/jasmine-core/spec/core/asymmetric_equality/AnySpec.js +8 -8
- data/lib/jasmine-core/spec/core/asymmetric_equality/AnythingSpec.js +7 -7
- data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayContainingSpec.js +6 -6
- data/lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js +11 -11
- data/lib/jasmine-core/spec/core/asymmetric_equality/StringMatchingSpec.js +4 -4
- data/lib/jasmine-core/spec/core/formatErrorMsgSpec.js +13 -0
- data/lib/jasmine-core/spec/core/integration/CustomMatchersSpec.js +2 -2
- data/lib/jasmine-core/spec/core/integration/EnvSpec.js +195 -76
- data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +20 -21
- data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +164 -114
- data/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js +4 -4
- data/lib/jasmine-core/spec/core/matchers/toBeDefinedSpec.js +2 -2
- data/lib/jasmine-core/spec/core/matchers/toBeFalsySpec.js +2 -2
- data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanOrEqualSpec.js +29 -0
- data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanSpec.js +2 -2
- data/lib/jasmine-core/spec/core/matchers/toBeLessThanOrEqualSpec.js +29 -0
- data/lib/jasmine-core/spec/core/matchers/toBeLessThanSpec.js +2 -2
- data/lib/jasmine-core/spec/core/matchers/toBeNaNSpec.js +3 -3
- data/lib/jasmine-core/spec/core/matchers/toBeNullSpec.js +2 -2
- data/lib/jasmine-core/spec/core/matchers/toBeSpec.js +2 -2
- data/lib/jasmine-core/spec/core/matchers/toBeTruthySpec.js +2 -2
- data/lib/jasmine-core/spec/core/matchers/toBeUndefinedSpec.js +2 -2
- data/lib/jasmine-core/spec/core/matchers/toContainSpec.js +4 -4
- data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +2 -2
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js +11 -11
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledTimesSpec.js +22 -17
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledWithSpec.js +11 -10
- data/lib/jasmine-core/spec/core/matchers/toMatchSpec.js +7 -6
- data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +24 -24
- data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +9 -8
- data/lib/jasmine-core/spec/helpers/defineJasmineUnderTest.js +3 -3
- data/lib/jasmine-core/spec/helpers/nodeDefineJasmineUnderTest.js +5 -5
- data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +95 -59
- data/lib/jasmine-core/spec/html/HtmlSpecFilterSpec.js +3 -3
- data/lib/jasmine-core/spec/html/MatchersHtmlSpec.js +1 -1
- data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +4 -4
- data/lib/jasmine-core/spec/html/QueryStringSpec.js +5 -5
- data/lib/jasmine-core/spec/html/ResultsNodeSpec.js +4 -4
- data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +2 -2
- data/lib/jasmine-core/spec/performance/large_object_test.js +1 -1
- data/lib/jasmine-core/version.rb +1 -1
- metadata +5 -3
- data/lib/jasmine-core/spec/node_suite.js +0 -195
@@ -1,7 +1,7 @@
|
|
1
1
|
describe("ReportDispatcher", function() {
|
2
2
|
|
3
3
|
it("builds an interface of requested methods", function() {
|
4
|
-
var dispatcher = new
|
4
|
+
var dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar', 'baz']);
|
5
5
|
|
6
6
|
expect(dispatcher.foo).toBeDefined();
|
7
7
|
expect(dispatcher.bar).toBeDefined();
|
@@ -9,7 +9,7 @@ describe("ReportDispatcher", function() {
|
|
9
9
|
});
|
10
10
|
|
11
11
|
it("dispatches requested methods to added reporters", function() {
|
12
|
-
var dispatcher = new
|
12
|
+
var dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar']),
|
13
13
|
reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']),
|
14
14
|
anotherReporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
|
15
15
|
|
@@ -28,7 +28,7 @@ describe("ReportDispatcher", function() {
|
|
28
28
|
});
|
29
29
|
|
30
30
|
it("does not dispatch to a reporter if the reporter doesn't accept the method", function() {
|
31
|
-
var dispatcher = new
|
31
|
+
var dispatcher = new jasmineUnderTest.ReportDispatcher(['foo']),
|
32
32
|
reporter = jasmine.createSpyObj('reporter', ['baz']);
|
33
33
|
|
34
34
|
dispatcher.addReporter(reporter);
|
@@ -37,4 +37,28 @@ describe("ReportDispatcher", function() {
|
|
37
37
|
dispatcher.foo(123, 456);
|
38
38
|
}).not.toThrow();
|
39
39
|
});
|
40
|
+
|
41
|
+
it("allows providing a fallback reporter in case there's no other report", function() {
|
42
|
+
var dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar']),
|
43
|
+
reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
|
44
|
+
|
45
|
+
dispatcher.provideFallbackReporter(reporter);
|
46
|
+
dispatcher.foo(123, 456);
|
47
|
+
expect(reporter.foo).toHaveBeenCalledWith(123, 456);
|
48
|
+
|
49
|
+
});
|
50
|
+
|
51
|
+
it("does not call fallback reporting methods when another report is provided", function() {
|
52
|
+
var dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar']),
|
53
|
+
reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']),
|
54
|
+
fallbackReporter = jasmine.createSpyObj('otherReporter', ['foo', 'bar']);
|
55
|
+
|
56
|
+
dispatcher.provideFallbackReporter(fallbackReporter);
|
57
|
+
dispatcher.addReporter(reporter);
|
58
|
+
dispatcher.foo(123, 456);
|
59
|
+
|
60
|
+
expect(reporter.foo).toHaveBeenCalledWith(123, 456);
|
61
|
+
expect(fallbackReporter.foo).not.toHaveBeenCalledWith(123, 456);
|
62
|
+
|
63
|
+
});
|
40
64
|
});
|
@@ -1,36 +1,36 @@
|
|
1
1
|
describe("Spec", function() {
|
2
2
|
|
3
3
|
it("#isPendingSpecException returns true for a pending spec exception", function() {
|
4
|
-
var e = new Error(
|
4
|
+
var e = new Error(jasmineUnderTest.Spec.pendingSpecExceptionMessage);
|
5
5
|
|
6
|
-
expect(
|
6
|
+
expect(jasmineUnderTest.Spec.isPendingSpecException(e)).toBe(true);
|
7
7
|
});
|
8
8
|
|
9
9
|
it("#isPendingSpecException returns true for a pending spec exception (even when FF bug is present)", function() {
|
10
10
|
var fakeError = {
|
11
|
-
toString: function() { return "Error: " +
|
11
|
+
toString: function() { return "Error: " + jasmineUnderTest.Spec.pendingSpecExceptionMessage; }
|
12
12
|
};
|
13
13
|
|
14
|
-
expect(
|
14
|
+
expect(jasmineUnderTest.Spec.isPendingSpecException(fakeError)).toBe(true);
|
15
15
|
});
|
16
16
|
|
17
17
|
it("#isPendingSpecException returns true for a pending spec exception with a custom message", function() {
|
18
|
-
expect(
|
18
|
+
expect(jasmineUnderTest.Spec.isPendingSpecException(jasmineUnderTest.Spec.pendingSpecExceptionMessage + 'foo')).toBe(true);
|
19
19
|
});
|
20
20
|
|
21
21
|
it("#isPendingSpecException returns false for not a pending spec exception", function() {
|
22
22
|
var e = new Error("foo");
|
23
23
|
|
24
|
-
expect(
|
24
|
+
expect(jasmineUnderTest.Spec.isPendingSpecException(e)).toBe(false);
|
25
25
|
});
|
26
26
|
|
27
27
|
it("#isPendingSpecException returns false for thrown values that don't have toString", function() {
|
28
|
-
expect(
|
28
|
+
expect(jasmineUnderTest.Spec.isPendingSpecException(void 0)).toBe(false);
|
29
29
|
});
|
30
30
|
|
31
31
|
it("delegates execution to a QueueRunner", function() {
|
32
32
|
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
|
33
|
-
spec = new
|
33
|
+
spec = new jasmineUnderTest.Spec({
|
34
34
|
description: 'my test',
|
35
35
|
id: 'some-id',
|
36
36
|
queueableFn: { fn: function() {} },
|
@@ -45,7 +45,7 @@ describe("Spec", function() {
|
|
45
45
|
it("should call the start callback on execution", function() {
|
46
46
|
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
|
47
47
|
startCallback = jasmine.createSpy('startCallback'),
|
48
|
-
spec = new
|
48
|
+
spec = new jasmineUnderTest.Spec({
|
49
49
|
id: 123,
|
50
50
|
description: 'foo bar',
|
51
51
|
queueableFn: { fn: function() {} },
|
@@ -69,7 +69,7 @@ describe("Spec", function() {
|
|
69
69
|
startCallback = jasmine.createSpy('start-callback').and.callFake(function() {
|
70
70
|
expect(beforesWereCalled).toBe(false);
|
71
71
|
}),
|
72
|
-
spec = new
|
72
|
+
spec = new jasmineUnderTest.Spec({
|
73
73
|
queueableFn: { fn: function() {} },
|
74
74
|
beforeFns: function() {
|
75
75
|
return [function() {
|
@@ -93,7 +93,7 @@ describe("Spec", function() {
|
|
93
93
|
expect(before).toHaveBeenCalled();
|
94
94
|
expect(after).not.toHaveBeenCalled();
|
95
95
|
}) },
|
96
|
-
spec = new
|
96
|
+
spec = new jasmineUnderTest.Spec({
|
97
97
|
queueableFn: queueableFn,
|
98
98
|
beforeAndAfterFns: function() {
|
99
99
|
return {befores: [before], afters: [after]}
|
@@ -112,7 +112,7 @@ describe("Spec", function() {
|
|
112
112
|
|
113
113
|
startCallback = jasmine.createSpy('startCallback'),
|
114
114
|
resultCallback = jasmine.createSpy('resultCallback'),
|
115
|
-
spec = new
|
115
|
+
spec = new jasmineUnderTest.Spec({
|
116
116
|
onStart: startCallback,
|
117
117
|
queueableFn: { fn: null },
|
118
118
|
resultCallback: resultCallback,
|
@@ -127,7 +127,7 @@ describe("Spec", function() {
|
|
127
127
|
startCallback = jasmine.createSpy('startCallback'),
|
128
128
|
specBody = jasmine.createSpy('specBody'),
|
129
129
|
resultCallback = jasmine.createSpy('resultCallback'),
|
130
|
-
spec = new
|
130
|
+
spec = new jasmineUnderTest.Spec({
|
131
131
|
onStart:startCallback,
|
132
132
|
queueableFn: { fn: specBody },
|
133
133
|
resultCallback: resultCallback,
|
@@ -152,7 +152,7 @@ describe("Spec", function() {
|
|
152
152
|
startCallback = jasmine.createSpy('startCallback'),
|
153
153
|
specBody = jasmine.createSpy('specBody'),
|
154
154
|
resultCallback = jasmine.createSpy('resultCallback'),
|
155
|
-
spec = new
|
155
|
+
spec = new jasmineUnderTest.Spec({
|
156
156
|
onStart:startCallback,
|
157
157
|
queueableFn: { fn: specBody },
|
158
158
|
resultCallback: resultCallback,
|
@@ -174,7 +174,7 @@ describe("Spec", function() {
|
|
174
174
|
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
|
175
175
|
startCallback = jasmine.createSpy('startCallback'),
|
176
176
|
resultCallback = jasmine.createSpy('resultCallback'),
|
177
|
-
spec = new
|
177
|
+
spec = new jasmineUnderTest.Spec({
|
178
178
|
onStart: startCallback,
|
179
179
|
resultCallback: resultCallback,
|
180
180
|
description: "with a spec",
|
@@ -207,7 +207,7 @@ describe("Spec", function() {
|
|
207
207
|
|
208
208
|
it("should call the done callback on execution complete", function() {
|
209
209
|
var done = jasmine.createSpy('done callback'),
|
210
|
-
spec = new
|
210
|
+
spec = new jasmineUnderTest.Spec({
|
211
211
|
queueableFn: { fn: function() {} },
|
212
212
|
catchExceptions: function() { return false; },
|
213
213
|
resultCallback: function() {},
|
@@ -220,18 +220,18 @@ describe("Spec", function() {
|
|
220
220
|
});
|
221
221
|
|
222
222
|
it("#status returns passing by default", function() {
|
223
|
-
var spec = new
|
223
|
+
var spec = new jasmineUnderTest.Spec({queueableFn: { fn: jasmine.createSpy("spec body")} });
|
224
224
|
expect(spec.status()).toBe('passed');
|
225
225
|
});
|
226
226
|
|
227
227
|
it("#status returns passed if all expectations in the spec have passed", function() {
|
228
|
-
var spec = new
|
228
|
+
var spec = new jasmineUnderTest.Spec({queueableFn: { fn: jasmine.createSpy("spec body")} });
|
229
229
|
spec.addExpectationResult(true);
|
230
230
|
expect(spec.status()).toBe('passed');
|
231
231
|
});
|
232
232
|
|
233
233
|
it("#status returns failed if any expectations in the spec have failed", function() {
|
234
|
-
var spec = new
|
234
|
+
var spec = new jasmineUnderTest.Spec({queueableFn: { fn: jasmine.createSpy("spec body") } });
|
235
235
|
spec.addExpectationResult(true);
|
236
236
|
spec.addExpectationResult(false);
|
237
237
|
expect(spec.status()).toBe('failed');
|
@@ -239,7 +239,7 @@ describe("Spec", function() {
|
|
239
239
|
|
240
240
|
it("keeps track of passed and failed expectations", function() {
|
241
241
|
var resultCallback = jasmine.createSpy('resultCallback'),
|
242
|
-
spec = new
|
242
|
+
spec = new jasmineUnderTest.Spec({
|
243
243
|
queueableFn: { fn: jasmine.createSpy("spec body") },
|
244
244
|
expectationResultFactory: function (data) { return data; },
|
245
245
|
queueRunnerFactory: function(attrs) { attrs.onComplete(); },
|
@@ -256,7 +256,7 @@ describe("Spec", function() {
|
|
256
256
|
|
257
257
|
it("throws an ExpectationFailed error upon receiving a failed expectation when 'throwOnExpectationFailure' is set", function() {
|
258
258
|
var resultCallback = jasmine.createSpy('resultCallback'),
|
259
|
-
spec = new
|
259
|
+
spec = new jasmineUnderTest.Spec({
|
260
260
|
queueableFn: { fn: function() {} },
|
261
261
|
expectationResultFactory: function(data) { return data; },
|
262
262
|
queueRunnerFactory: function(attrs) { attrs.onComplete(); },
|
@@ -267,7 +267,7 @@ describe("Spec", function() {
|
|
267
267
|
spec.addExpectationResult(true, 'passed');
|
268
268
|
expect(function() {
|
269
269
|
spec.addExpectationResult(false, 'failed')
|
270
|
-
}).toThrowError(
|
270
|
+
}).toThrowError(jasmineUnderTest.errors.ExpectationFailed);
|
271
271
|
|
272
272
|
spec.execute();
|
273
273
|
|
@@ -277,7 +277,7 @@ describe("Spec", function() {
|
|
277
277
|
|
278
278
|
it("does not throw an ExpectationFailed error when handling an error", function() {
|
279
279
|
var resultCallback = jasmine.createSpy('resultCallback'),
|
280
|
-
spec = new
|
280
|
+
spec = new jasmineUnderTest.Spec({
|
281
281
|
queueableFn: { fn: function() {} },
|
282
282
|
expectationResultFactory: function(data) { return data; },
|
283
283
|
queueRunnerFactory: function(attrs) { attrs.onComplete(); },
|
@@ -291,7 +291,7 @@ describe("Spec", function() {
|
|
291
291
|
it("can return its full name", function() {
|
292
292
|
var specNameSpy = jasmine.createSpy('specNameSpy').and.returnValue('expected val');
|
293
293
|
|
294
|
-
var spec = new
|
294
|
+
var spec = new jasmineUnderTest.Spec({
|
295
295
|
getSpecName: specNameSpy,
|
296
296
|
queueableFn: { fn: null }
|
297
297
|
});
|
@@ -303,9 +303,9 @@ describe("Spec", function() {
|
|
303
303
|
describe("when a spec is marked pending during execution", function() {
|
304
304
|
it("should mark the spec as pending", function() {
|
305
305
|
var fakeQueueRunner = function(opts) {
|
306
|
-
opts.onException(new Error(
|
306
|
+
opts.onException(new Error(jasmineUnderTest.Spec.pendingSpecExceptionMessage));
|
307
307
|
},
|
308
|
-
spec = new
|
308
|
+
spec = new jasmineUnderTest.Spec({
|
309
309
|
description: 'my test',
|
310
310
|
id: 'some-id',
|
311
311
|
queueableFn: { fn: function() { } },
|
@@ -320,9 +320,9 @@ describe("Spec", function() {
|
|
320
320
|
|
321
321
|
it("should set the pendingReason", function() {
|
322
322
|
var fakeQueueRunner = function(opts) {
|
323
|
-
opts.onException(new Error(
|
323
|
+
opts.onException(new Error(jasmineUnderTest.Spec.pendingSpecExceptionMessage + 'custom message'));
|
324
324
|
},
|
325
|
-
spec = new
|
325
|
+
spec = new jasmineUnderTest.Spec({
|
326
326
|
description: 'my test',
|
327
327
|
id: 'some-id',
|
328
328
|
queueableFn: { fn: function() { } },
|
@@ -338,7 +338,7 @@ describe("Spec", function() {
|
|
338
338
|
|
339
339
|
it("should log a failure when handling an exception", function() {
|
340
340
|
var resultCallback = jasmine.createSpy('resultCallback'),
|
341
|
-
spec = new
|
341
|
+
spec = new jasmineUnderTest.Spec({
|
342
342
|
queueableFn: { fn: function() {} },
|
343
343
|
expectationResultFactory: function(data) { return data; },
|
344
344
|
queueRunnerFactory: function(attrs) { attrs.onComplete(); },
|
@@ -359,41 +359,41 @@ describe("Spec", function() {
|
|
359
359
|
|
360
360
|
it("should not log an additional failure when handling an ExpectationFailed error", function() {
|
361
361
|
var resultCallback = jasmine.createSpy('resultCallback'),
|
362
|
-
spec = new
|
362
|
+
spec = new jasmineUnderTest.Spec({
|
363
363
|
queueableFn: { fn: function() {} },
|
364
364
|
expectationResultFactory: function(data) { return data; },
|
365
365
|
queueRunnerFactory: function(attrs) { attrs.onComplete(); },
|
366
366
|
resultCallback: resultCallback
|
367
367
|
});
|
368
368
|
|
369
|
-
spec.onException(new
|
369
|
+
spec.onException(new jasmineUnderTest.errors.ExpectationFailed());
|
370
370
|
spec.execute();
|
371
371
|
|
372
372
|
expect(resultCallback.calls.first().args[0].failedExpectations).toEqual([]);
|
373
373
|
});
|
374
374
|
|
375
375
|
it("retrieves a result with updated status", function() {
|
376
|
-
var spec = new
|
376
|
+
var spec = new jasmineUnderTest.Spec({ queueableFn: { fn: function() {} } });
|
377
377
|
|
378
378
|
expect(spec.getResult().status).toBe('passed');
|
379
379
|
});
|
380
380
|
|
381
381
|
it("retrives a result with disabled status", function() {
|
382
|
-
var spec = new
|
382
|
+
var spec = new jasmineUnderTest.Spec({ queueableFn: { fn: function() {} } });
|
383
383
|
spec.disable();
|
384
384
|
|
385
385
|
expect(spec.getResult().status).toBe('disabled');
|
386
386
|
});
|
387
387
|
|
388
388
|
it("retrives a result with pending status", function() {
|
389
|
-
var spec = new
|
389
|
+
var spec = new jasmineUnderTest.Spec({ queueableFn: { fn: function() {} } });
|
390
390
|
spec.pend();
|
391
391
|
|
392
392
|
expect(spec.getResult().status).toBe('pending');
|
393
393
|
});
|
394
394
|
|
395
395
|
it("should not be executable when disabled", function() {
|
396
|
-
var spec = new
|
396
|
+
var spec = new jasmineUnderTest.Spec({
|
397
397
|
queueableFn: { fn: function() {} }
|
398
398
|
});
|
399
399
|
spec.disable();
|
@@ -402,7 +402,7 @@ describe("Spec", function() {
|
|
402
402
|
});
|
403
403
|
|
404
404
|
it("should be executable when pending", function() {
|
405
|
-
var spec = new
|
405
|
+
var spec = new jasmineUnderTest.Spec({
|
406
406
|
queueableFn: { fn: function() {} }
|
407
407
|
});
|
408
408
|
spec.pend();
|
@@ -411,7 +411,7 @@ describe("Spec", function() {
|
|
411
411
|
});
|
412
412
|
|
413
413
|
it("should be executable when not disabled or pending", function() {
|
414
|
-
var spec = new
|
414
|
+
var spec = new jasmineUnderTest.Spec({
|
415
415
|
queueableFn: { fn: function() {} }
|
416
416
|
});
|
417
417
|
|
@@ -1,14 +1,14 @@
|
|
1
1
|
describe("SpyRegistry", function() {
|
2
2
|
describe("#spyOn", function() {
|
3
3
|
it("checks for the existence of the object", function() {
|
4
|
-
var spyRegistry = new
|
4
|
+
var spyRegistry = new jasmineUnderTest.SpyRegistry();
|
5
5
|
expect(function() {
|
6
6
|
spyRegistry.spyOn(void 0, 'pants');
|
7
7
|
}).toThrowError(/could not find an object/);
|
8
8
|
});
|
9
9
|
|
10
10
|
it("checks that a method name was passed", function() {
|
11
|
-
var spyRegistry = new
|
11
|
+
var spyRegistry = new jasmineUnderTest.SpyRegistry(),
|
12
12
|
subject = {};
|
13
13
|
|
14
14
|
expect(function() {
|
@@ -17,7 +17,7 @@ describe("SpyRegistry", function() {
|
|
17
17
|
});
|
18
18
|
|
19
19
|
it("checks for the existence of the method", function() {
|
20
|
-
var spyRegistry = new
|
20
|
+
var spyRegistry = new jasmineUnderTest.SpyRegistry(),
|
21
21
|
subject = {};
|
22
22
|
|
23
23
|
expect(function() {
|
@@ -27,7 +27,7 @@ describe("SpyRegistry", function() {
|
|
27
27
|
|
28
28
|
it("checks if it has already been spied upon", function() {
|
29
29
|
var spies = [],
|
30
|
-
spyRegistry = new
|
30
|
+
spyRegistry = new jasmineUnderTest.SpyRegistry({currentSpies: function() { return spies; }}),
|
31
31
|
subject = { spiedFunc: function() {} };
|
32
32
|
|
33
33
|
spyRegistry.spyOn(subject, 'spiedFunc');
|
@@ -54,7 +54,7 @@ describe("SpyRegistry", function() {
|
|
54
54
|
});
|
55
55
|
|
56
56
|
var spies = [],
|
57
|
-
spyRegistry = new
|
57
|
+
spyRegistry = new jasmineUnderTest.SpyRegistry({currentSpies: function() { return spies; }}),
|
58
58
|
subject = { spiedFunc: scope.myFunc };
|
59
59
|
|
60
60
|
expect(function() {
|
@@ -68,7 +68,7 @@ describe("SpyRegistry", function() {
|
|
68
68
|
|
69
69
|
it("overrides the method on the object and returns the spy", function() {
|
70
70
|
var originalFunctionWasCalled = false,
|
71
|
-
spyRegistry = new
|
71
|
+
spyRegistry = new jasmineUnderTest.SpyRegistry(),
|
72
72
|
subject = { spiedFunc: function() { originalFunctionWasCalled = true; } };
|
73
73
|
|
74
74
|
var spy = spyRegistry.spyOn(subject, 'spiedFunc');
|
@@ -80,7 +80,7 @@ describe("SpyRegistry", function() {
|
|
80
80
|
describe("#clearSpies", function() {
|
81
81
|
it("restores the original functions on the spied-upon objects", function() {
|
82
82
|
var spies = [],
|
83
|
-
spyRegistry = new
|
83
|
+
spyRegistry = new jasmineUnderTest.SpyRegistry({currentSpies: function() { return spies; }}),
|
84
84
|
originalFunction = function() {},
|
85
85
|
subject = { spiedFunc: originalFunction };
|
86
86
|
|
@@ -89,5 +89,44 @@ describe("SpyRegistry", function() {
|
|
89
89
|
|
90
90
|
expect(subject.spiedFunc).toBe(originalFunction);
|
91
91
|
});
|
92
|
+
|
93
|
+
it("restores the original functions, even when that spy has been replace and re-spied upon", function() {
|
94
|
+
var spies = [],
|
95
|
+
spyRegistry = new jasmineUnderTest.SpyRegistry({currentSpies: function() { return spies; }}),
|
96
|
+
originalFunction = function() {},
|
97
|
+
subject = { spiedFunc: originalFunction };
|
98
|
+
|
99
|
+
spyRegistry.spyOn(subject, 'spiedFunc');
|
100
|
+
|
101
|
+
// replace the original spy with some other function
|
102
|
+
subject.spiedFunc = function() {};
|
103
|
+
|
104
|
+
// spy on the function in that location again
|
105
|
+
spyRegistry.spyOn(subject, 'spiedFunc');
|
106
|
+
|
107
|
+
spyRegistry.clearSpies();
|
108
|
+
|
109
|
+
expect(subject.spiedFunc).toBe(originalFunction);
|
110
|
+
});
|
111
|
+
|
112
|
+
it("does not add a property that the spied-upon object didn't originally have", function() {
|
113
|
+
// IE 8 doesn't support `Object.create`
|
114
|
+
if (jasmine.getEnv().ieVersion < 9) { return; }
|
115
|
+
|
116
|
+
var spies = [],
|
117
|
+
spyRegistry = new jasmineUnderTest.SpyRegistry({currentSpies: function() { return spies; }}),
|
118
|
+
originalFunction = function() {},
|
119
|
+
subjectParent = {spiedFunc: originalFunction};
|
120
|
+
|
121
|
+
var subject = Object.create(subjectParent);
|
122
|
+
|
123
|
+
expect(subject.hasOwnProperty('spiedFunc')).toBe(false);
|
124
|
+
|
125
|
+
spyRegistry.spyOn(subject, 'spiedFunc');
|
126
|
+
spyRegistry.clearSpies();
|
127
|
+
|
128
|
+
expect(subject.hasOwnProperty('spiedFunc')).toBe(false);
|
129
|
+
expect(subject.spiedFunc).toBe(originalFunction);
|
130
|
+
})
|
92
131
|
});
|
93
132
|
});
|
@@ -9,7 +9,7 @@ describe('Spies', function () {
|
|
9
9
|
});
|
10
10
|
|
11
11
|
it("preserves the properties of the spied function", function() {
|
12
|
-
var spy =
|
12
|
+
var spy = jasmineUnderTest.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
13
13
|
|
14
14
|
expect(spy.bob).toEqual("test");
|
15
15
|
});
|
@@ -18,19 +18,19 @@ describe('Spies', function () {
|
|
18
18
|
TestClass.prototype.someFunction.and = "turkey";
|
19
19
|
|
20
20
|
expect(function() {
|
21
|
-
|
21
|
+
jasmineUnderTest.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
22
22
|
}).toThrowError("Jasmine spies would overwrite the 'and' and 'calls' properties on the object being spied upon");
|
23
23
|
});
|
24
24
|
|
25
25
|
it("adds a spyStrategy and callTracker to the spy", function() {
|
26
|
-
var spy =
|
26
|
+
var spy = jasmineUnderTest.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
27
27
|
|
28
|
-
expect(spy.and).toEqual(jasmine.any(
|
29
|
-
expect(spy.calls).toEqual(jasmine.any(
|
28
|
+
expect(spy.and).toEqual(jasmine.any(jasmineUnderTest.SpyStrategy));
|
29
|
+
expect(spy.calls).toEqual(jasmine.any(jasmineUnderTest.CallTracker));
|
30
30
|
});
|
31
31
|
|
32
32
|
it("tracks the argument of calls", function () {
|
33
|
-
var spy =
|
33
|
+
var spy = jasmineUnderTest.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
34
34
|
var trackSpy = spyOn(spy.calls, "track");
|
35
35
|
|
36
36
|
spy("arg");
|
@@ -39,7 +39,7 @@ describe('Spies', function () {
|
|
39
39
|
});
|
40
40
|
|
41
41
|
it("tracks the context of calls", function () {
|
42
|
-
var spy =
|
42
|
+
var spy = jasmineUnderTest.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
43
43
|
var trackSpy = spyOn(spy.calls, "track");
|
44
44
|
|
45
45
|
var contextObject = { spyMethod: spy };
|
@@ -49,7 +49,7 @@ describe('Spies', function () {
|
|
49
49
|
});
|
50
50
|
|
51
51
|
it("tracks the return value of calls", function () {
|
52
|
-
var spy =
|
52
|
+
var spy = jasmineUnderTest.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
53
53
|
var trackSpy = spyOn(spy.calls, "track");
|
54
54
|
|
55
55
|
spy.and.returnValue("return value");
|
@@ -61,7 +61,7 @@ describe('Spies', function () {
|
|
61
61
|
|
62
62
|
describe("createSpyObj", function() {
|
63
63
|
it("should create an object with a bunch of spy methods when you call jasmine.createSpyObj()", function() {
|
64
|
-
var spyObj =
|
64
|
+
var spyObj = jasmineUnderTest.createSpyObj('BaseName', ['method1', 'method2']);
|
65
65
|
|
66
66
|
expect(spyObj).toEqual({ method1: jasmine.any(Function), method2: jasmine.any(Function)});
|
67
67
|
expect(spyObj.method1.and.identity()).toEqual('BaseName.method1');
|
@@ -69,7 +69,7 @@ describe('Spies', function () {
|
|
69
69
|
});
|
70
70
|
|
71
71
|
it("should allow you to omit the baseName", function() {
|
72
|
-
var spyObj =
|
72
|
+
var spyObj = jasmineUnderTest.createSpyObj(['method1', 'method2']);
|
73
73
|
|
74
74
|
expect(spyObj).toEqual({ method1: jasmine.any(Function), method2: jasmine.any(Function)});
|
75
75
|
expect(spyObj.method1.and.identity()).toEqual('unknown.method1');
|
@@ -78,7 +78,7 @@ describe('Spies', function () {
|
|
78
78
|
|
79
79
|
it("should throw if you do not pass an array argument", function() {
|
80
80
|
expect(function() {
|
81
|
-
|
81
|
+
jasmineUnderTest.createSpyObj('BaseName');
|
82
82
|
}).toThrow("createSpyObj requires a non-empty array of method names to create spies for");
|
83
83
|
});
|
84
84
|
});
|