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,140 +0,0 @@
|
|
1
|
-
describe("ReportDispatcher", function() {
|
2
|
-
|
3
|
-
it("builds an interface of requested methods", function() {
|
4
|
-
var dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar', 'baz']);
|
5
|
-
|
6
|
-
expect(dispatcher.foo).toBeDefined();
|
7
|
-
expect(dispatcher.bar).toBeDefined();
|
8
|
-
expect(dispatcher.baz).toBeDefined();
|
9
|
-
});
|
10
|
-
|
11
|
-
it("dispatches requested methods to added reporters", function() {
|
12
|
-
var queueRunnerFactory = jasmine.createSpy('queueRunner'),
|
13
|
-
dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar'], queueRunnerFactory),
|
14
|
-
reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']),
|
15
|
-
anotherReporter = jasmine.createSpyObj('reporter', ['foo', 'bar']),
|
16
|
-
completeCallback = jasmine.createSpy('complete');
|
17
|
-
|
18
|
-
dispatcher.addReporter(reporter);
|
19
|
-
dispatcher.addReporter(anotherReporter);
|
20
|
-
|
21
|
-
dispatcher.foo(123, 456, completeCallback);
|
22
|
-
|
23
|
-
expect(queueRunnerFactory).toHaveBeenCalledWith(jasmine.objectContaining({
|
24
|
-
queueableFns: [{fn: jasmine.any(Function)}, {fn: jasmine.any(Function)}],
|
25
|
-
isReporter: true
|
26
|
-
}));
|
27
|
-
|
28
|
-
var fns = queueRunnerFactory.calls.mostRecent().args[0].queueableFns;
|
29
|
-
fns[0].fn();
|
30
|
-
expect(reporter.foo).toHaveBeenCalledWith(123, 456);
|
31
|
-
expect(reporter.foo.calls.mostRecent().object).toBe(reporter);
|
32
|
-
|
33
|
-
fns[1].fn();
|
34
|
-
expect(anotherReporter.foo).toHaveBeenCalledWith(123, 456);
|
35
|
-
expect(anotherReporter.foo.calls.mostRecent().object).toBe(anotherReporter);
|
36
|
-
|
37
|
-
queueRunnerFactory.calls.reset();
|
38
|
-
|
39
|
-
dispatcher.bar('a', 'b', completeCallback);
|
40
|
-
|
41
|
-
expect(queueRunnerFactory).toHaveBeenCalledWith(jasmine.objectContaining({
|
42
|
-
queueableFns: [{fn: jasmine.any(Function)}, {fn: jasmine.any(Function)}],
|
43
|
-
isReporter: true
|
44
|
-
}));
|
45
|
-
|
46
|
-
fns = queueRunnerFactory.calls.mostRecent().args[0].queueableFns;
|
47
|
-
fns[0].fn();
|
48
|
-
expect(reporter.bar).toHaveBeenCalledWith('a', 'b');
|
49
|
-
|
50
|
-
fns[1].fn();
|
51
|
-
expect(anotherReporter.bar).toHaveBeenCalledWith('a', 'b');
|
52
|
-
});
|
53
|
-
|
54
|
-
it("does not dispatch to a reporter if the reporter doesn't accept the method", function() {
|
55
|
-
var queueRunnerFactory = jasmine.createSpy('queueRunner'),
|
56
|
-
dispatcher = new jasmineUnderTest.ReportDispatcher(['foo'], queueRunnerFactory),
|
57
|
-
reporter = jasmine.createSpyObj('reporter', ['baz']);
|
58
|
-
|
59
|
-
dispatcher.addReporter(reporter);
|
60
|
-
|
61
|
-
dispatcher.foo(123, 456);
|
62
|
-
expect(queueRunnerFactory).toHaveBeenCalledWith(jasmine.objectContaining({
|
63
|
-
queueableFns: []
|
64
|
-
}));
|
65
|
-
});
|
66
|
-
|
67
|
-
it("allows providing a fallback reporter in case there's no other reporter", function() {
|
68
|
-
var queueRunnerFactory = jasmine.createSpy('queueRunner'),
|
69
|
-
dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar'], queueRunnerFactory),
|
70
|
-
reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']),
|
71
|
-
completeCallback = jasmine.createSpy('complete');
|
72
|
-
|
73
|
-
dispatcher.provideFallbackReporter(reporter);
|
74
|
-
dispatcher.foo(123, 456, completeCallback);
|
75
|
-
|
76
|
-
expect(queueRunnerFactory).toHaveBeenCalledWith(jasmine.objectContaining({
|
77
|
-
queueableFns: [{fn: jasmine.any(Function)}],
|
78
|
-
isReporter: true
|
79
|
-
}));
|
80
|
-
|
81
|
-
var fns = queueRunnerFactory.calls.mostRecent().args[0].queueableFns;
|
82
|
-
fns[0].fn();
|
83
|
-
expect(reporter.foo).toHaveBeenCalledWith(123, 456);
|
84
|
-
});
|
85
|
-
|
86
|
-
it("does not call fallback reporting methods when another reporter is provided", function() {
|
87
|
-
var queueRunnerFactory = jasmine.createSpy('queueRunner'),
|
88
|
-
dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar'], queueRunnerFactory),
|
89
|
-
reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']),
|
90
|
-
fallbackReporter = jasmine.createSpyObj('otherReporter', ['foo', 'bar']),
|
91
|
-
completeCallback = jasmine.createSpy('complete');
|
92
|
-
|
93
|
-
dispatcher.provideFallbackReporter(fallbackReporter);
|
94
|
-
dispatcher.addReporter(reporter);
|
95
|
-
dispatcher.foo(123, 456, completeCallback);
|
96
|
-
|
97
|
-
expect(queueRunnerFactory).toHaveBeenCalledWith(jasmine.objectContaining({
|
98
|
-
queueableFns: [{fn: jasmine.any(Function)}],
|
99
|
-
isReporter: true
|
100
|
-
}));
|
101
|
-
|
102
|
-
var fns = queueRunnerFactory.calls.mostRecent().args[0].queueableFns;
|
103
|
-
fns[0].fn();
|
104
|
-
expect(reporter.foo).toHaveBeenCalledWith(123, 456);
|
105
|
-
expect(fallbackReporter.foo).not.toHaveBeenCalledWith(123, 456);
|
106
|
-
});
|
107
|
-
|
108
|
-
it("allows registered reporters to be cleared", function() {
|
109
|
-
var queueRunnerFactory = jasmine.createSpy('queueRunner'),
|
110
|
-
dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar'], queueRunnerFactory),
|
111
|
-
reporter1 = jasmine.createSpyObj('reporter1', ['foo', 'bar']),
|
112
|
-
reporter2 = jasmine.createSpyObj('reporter2', ['foo', 'bar']),
|
113
|
-
completeCallback = jasmine.createSpy('complete');
|
114
|
-
|
115
|
-
dispatcher.addReporter(reporter1);
|
116
|
-
dispatcher.foo(123, completeCallback);
|
117
|
-
expect(queueRunnerFactory).toHaveBeenCalledWith(jasmine.objectContaining({
|
118
|
-
queueableFns: [{fn: jasmine.any(Function)}],
|
119
|
-
isReporter: true
|
120
|
-
}));
|
121
|
-
|
122
|
-
var fns = queueRunnerFactory.calls.mostRecent().args[0].queueableFns;
|
123
|
-
fns[0].fn();
|
124
|
-
expect(reporter1.foo).toHaveBeenCalledWith(123);
|
125
|
-
|
126
|
-
dispatcher.clearReporters();
|
127
|
-
dispatcher.addReporter(reporter2);
|
128
|
-
dispatcher.bar(456, completeCallback);
|
129
|
-
|
130
|
-
expect(queueRunnerFactory).toHaveBeenCalledWith(jasmine.objectContaining({
|
131
|
-
queueableFns: [{fn: jasmine.any(Function)}],
|
132
|
-
isReporter: true
|
133
|
-
}));
|
134
|
-
|
135
|
-
fns = queueRunnerFactory.calls.mostRecent().args[0].queueableFns;
|
136
|
-
fns[0].fn();
|
137
|
-
expect(reporter1.bar).not.toHaveBeenCalled();
|
138
|
-
expect(reporter2.bar).toHaveBeenCalledWith(456);
|
139
|
-
});
|
140
|
-
});
|
@@ -1,407 +0,0 @@
|
|
1
|
-
describe("Spec", function() {
|
2
|
-
|
3
|
-
it("#isPendingSpecException returns true for a pending spec exception", function() {
|
4
|
-
var e = new Error(jasmineUnderTest.Spec.pendingSpecExceptionMessage);
|
5
|
-
|
6
|
-
expect(jasmineUnderTest.Spec.isPendingSpecException(e)).toBe(true);
|
7
|
-
});
|
8
|
-
|
9
|
-
it("#isPendingSpecException returns true for a pending spec exception (even when FF bug is present)", function() {
|
10
|
-
var fakeError = {
|
11
|
-
toString: function() { return "Error: " + jasmineUnderTest.Spec.pendingSpecExceptionMessage; }
|
12
|
-
};
|
13
|
-
|
14
|
-
expect(jasmineUnderTest.Spec.isPendingSpecException(fakeError)).toBe(true);
|
15
|
-
});
|
16
|
-
|
17
|
-
it("#isPendingSpecException returns true for a pending spec exception with a custom message", function() {
|
18
|
-
expect(jasmineUnderTest.Spec.isPendingSpecException(jasmineUnderTest.Spec.pendingSpecExceptionMessage + 'foo')).toBe(true);
|
19
|
-
});
|
20
|
-
|
21
|
-
it("#isPendingSpecException returns false for not a pending spec exception", function() {
|
22
|
-
var e = new Error("foo");
|
23
|
-
|
24
|
-
expect(jasmineUnderTest.Spec.isPendingSpecException(e)).toBe(false);
|
25
|
-
});
|
26
|
-
|
27
|
-
it("#isPendingSpecException returns false for thrown values that don't have toString", function() {
|
28
|
-
expect(jasmineUnderTest.Spec.isPendingSpecException(void 0)).toBe(false);
|
29
|
-
});
|
30
|
-
|
31
|
-
it("delegates execution to a QueueRunner", function() {
|
32
|
-
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
|
33
|
-
spec = new jasmineUnderTest.Spec({
|
34
|
-
description: 'my test',
|
35
|
-
id: 'some-id',
|
36
|
-
queueableFn: { fn: function() {} },
|
37
|
-
queueRunnerFactory: fakeQueueRunner
|
38
|
-
});
|
39
|
-
|
40
|
-
spec.execute();
|
41
|
-
|
42
|
-
expect(fakeQueueRunner).toHaveBeenCalled();
|
43
|
-
});
|
44
|
-
|
45
|
-
it("should call the start callback on execution", function() {
|
46
|
-
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
|
47
|
-
startCallback = jasmine.createSpy('startCallback'),
|
48
|
-
spec = new jasmineUnderTest.Spec({
|
49
|
-
id: 123,
|
50
|
-
description: 'foo bar',
|
51
|
-
queueableFn: { fn: function() {} },
|
52
|
-
onStart: startCallback,
|
53
|
-
queueRunnerFactory: fakeQueueRunner
|
54
|
-
});
|
55
|
-
|
56
|
-
spec.execute();
|
57
|
-
|
58
|
-
fakeQueueRunner.calls.mostRecent().args[0].queueableFns[0].fn();
|
59
|
-
// TODO: due to some issue with the Pretty Printer, this line fails, but the other two pass.
|
60
|
-
// This means toHaveBeenCalledWith on IE8 will always be broken.
|
61
|
-
|
62
|
-
// expect(startCallback).toHaveBeenCalledWith(spec);
|
63
|
-
expect(startCallback).toHaveBeenCalled();
|
64
|
-
expect(startCallback.calls.first().object).toEqual(spec);
|
65
|
-
});
|
66
|
-
|
67
|
-
it("should call the start callback on execution but before any befores are called", function() {
|
68
|
-
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
|
69
|
-
beforesWereCalled = false,
|
70
|
-
startCallback = jasmine.createSpy('start-callback').and.callFake(function() {
|
71
|
-
expect(beforesWereCalled).toBe(false);
|
72
|
-
}),
|
73
|
-
spec = new jasmineUnderTest.Spec({
|
74
|
-
queueableFn: { fn: function() {} },
|
75
|
-
beforeFns: function() {
|
76
|
-
return [function() {
|
77
|
-
beforesWereCalled = true
|
78
|
-
}]
|
79
|
-
},
|
80
|
-
onStart: startCallback,
|
81
|
-
queueRunnerFactory: fakeQueueRunner
|
82
|
-
});
|
83
|
-
|
84
|
-
spec.execute();
|
85
|
-
|
86
|
-
fakeQueueRunner.calls.mostRecent().args[0].queueableFns[0].fn();
|
87
|
-
expect(startCallback).toHaveBeenCalled();
|
88
|
-
});
|
89
|
-
|
90
|
-
it("provides all before fns and after fns to be run", function() {
|
91
|
-
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
|
92
|
-
before = jasmine.createSpy('before'),
|
93
|
-
after = jasmine.createSpy('after'),
|
94
|
-
queueableFn = { fn: jasmine.createSpy('test body').and.callFake(function() {
|
95
|
-
expect(before).toHaveBeenCalled();
|
96
|
-
expect(after).not.toHaveBeenCalled();
|
97
|
-
}) },
|
98
|
-
spec = new jasmineUnderTest.Spec({
|
99
|
-
queueableFn: queueableFn,
|
100
|
-
beforeAndAfterFns: function() {
|
101
|
-
return {befores: [before], afters: [after]}
|
102
|
-
},
|
103
|
-
queueRunnerFactory: fakeQueueRunner
|
104
|
-
});
|
105
|
-
|
106
|
-
spec.execute();
|
107
|
-
|
108
|
-
var options = fakeQueueRunner.calls.mostRecent().args[0];
|
109
|
-
expect(options.queueableFns).toEqual([{fn: jasmine.any(Function)}, before, queueableFn]);
|
110
|
-
expect(options.cleanupFns).toEqual([after, {fn: jasmine.any(Function)}]);
|
111
|
-
});
|
112
|
-
|
113
|
-
it("tells the queue runner that it's a leaf node", function() {
|
114
|
-
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
|
115
|
-
spec = new jasmineUnderTest.Spec({
|
116
|
-
queueableFn: { fn: function() {} },
|
117
|
-
beforeAndAfterFns: function() {
|
118
|
-
return {befores: [], afters: []}
|
119
|
-
},
|
120
|
-
queueRunnerFactory: fakeQueueRunner
|
121
|
-
});
|
122
|
-
|
123
|
-
spec.execute();
|
124
|
-
|
125
|
-
expect(fakeQueueRunner).toHaveBeenCalledWith(jasmine.objectContaining({
|
126
|
-
isLeaf: true
|
127
|
-
}));
|
128
|
-
});
|
129
|
-
|
130
|
-
it("is marked pending if created without a function body", function() {
|
131
|
-
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
|
132
|
-
|
133
|
-
startCallback = jasmine.createSpy('startCallback'),
|
134
|
-
resultCallback = jasmine.createSpy('resultCallback'),
|
135
|
-
spec = new jasmineUnderTest.Spec({
|
136
|
-
onStart: startCallback,
|
137
|
-
queueableFn: { fn: null },
|
138
|
-
resultCallback: resultCallback,
|
139
|
-
queueRunnerFactory: fakeQueueRunner
|
140
|
-
});
|
141
|
-
|
142
|
-
expect(spec.status()).toBe('pending');
|
143
|
-
});
|
144
|
-
|
145
|
-
it("can be excluded at execution time by a parent", function() {
|
146
|
-
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
|
147
|
-
startCallback = jasmine.createSpy('startCallback'),
|
148
|
-
specBody = jasmine.createSpy('specBody'),
|
149
|
-
resultCallback = jasmine.createSpy('resultCallback'),
|
150
|
-
spec = new jasmineUnderTest.Spec({
|
151
|
-
onStart:startCallback,
|
152
|
-
queueableFn: { fn: specBody },
|
153
|
-
resultCallback: resultCallback,
|
154
|
-
queueRunnerFactory: fakeQueueRunner
|
155
|
-
});
|
156
|
-
|
157
|
-
spec.execute('cally-back', true);
|
158
|
-
|
159
|
-
expect(fakeQueueRunner).toHaveBeenCalledWith(jasmine.objectContaining({
|
160
|
-
onComplete: jasmine.any(Function),
|
161
|
-
queueableFns: [{fn: jasmine.any(Function)}],
|
162
|
-
cleanupFns: [{fn: jasmine.any(Function)}]
|
163
|
-
}));
|
164
|
-
expect(specBody).not.toHaveBeenCalled();
|
165
|
-
|
166
|
-
var args = fakeQueueRunner.calls.mostRecent().args[0];
|
167
|
-
args.queueableFns[0].fn();
|
168
|
-
expect(startCallback).toHaveBeenCalled();
|
169
|
-
args.cleanupFns[0].fn();
|
170
|
-
expect(resultCallback).toHaveBeenCalled();
|
171
|
-
|
172
|
-
expect(spec.result.status).toBe('excluded');
|
173
|
-
});
|
174
|
-
|
175
|
-
it("can be marked pending, but still calls callbacks when executed", function() {
|
176
|
-
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
|
177
|
-
startCallback = jasmine.createSpy('startCallback'),
|
178
|
-
resultCallback = jasmine.createSpy('resultCallback'),
|
179
|
-
spec = new jasmineUnderTest.Spec({
|
180
|
-
onStart: startCallback,
|
181
|
-
resultCallback: resultCallback,
|
182
|
-
description: "with a spec",
|
183
|
-
getSpecName: function() {
|
184
|
-
return "a suite with a spec"
|
185
|
-
},
|
186
|
-
queueRunnerFactory: fakeQueueRunner,
|
187
|
-
queueableFn: { fn: null }
|
188
|
-
});
|
189
|
-
|
190
|
-
spec.pend();
|
191
|
-
|
192
|
-
expect(spec.status()).toBe('pending');
|
193
|
-
|
194
|
-
spec.execute();
|
195
|
-
|
196
|
-
expect(fakeQueueRunner).toHaveBeenCalled();
|
197
|
-
|
198
|
-
var args = fakeQueueRunner.calls.mostRecent().args[0];
|
199
|
-
args.queueableFns[0].fn();
|
200
|
-
expect(startCallback).toHaveBeenCalled();
|
201
|
-
args.cleanupFns[0].fn('things');
|
202
|
-
expect(resultCallback).toHaveBeenCalledWith({
|
203
|
-
id: spec.id,
|
204
|
-
status: 'pending',
|
205
|
-
description: 'with a spec',
|
206
|
-
fullName: 'a suite with a spec',
|
207
|
-
failedExpectations: [],
|
208
|
-
passedExpectations: [],
|
209
|
-
deprecationWarnings: [],
|
210
|
-
pendingReason: ''
|
211
|
-
}, 'things');
|
212
|
-
});
|
213
|
-
|
214
|
-
it("should call the done callback on execution complete", function() {
|
215
|
-
var done = jasmine.createSpy('done callback'),
|
216
|
-
spec = new jasmineUnderTest.Spec({
|
217
|
-
queueableFn: { fn: function() {} },
|
218
|
-
catchExceptions: function() { return false; },
|
219
|
-
resultCallback: function() {},
|
220
|
-
queueRunnerFactory: function(attrs) { attrs.onComplete(); }
|
221
|
-
});
|
222
|
-
|
223
|
-
spec.execute(done);
|
224
|
-
|
225
|
-
expect(done).toHaveBeenCalled();
|
226
|
-
});
|
227
|
-
|
228
|
-
it("should call the done callback with an error if the spec is failed", function() {
|
229
|
-
var done = jasmine.createSpy('done callback'),
|
230
|
-
spec = new jasmineUnderTest.Spec({
|
231
|
-
queueableFn: { fn: function() {} },
|
232
|
-
catchExceptions: function() { return false; },
|
233
|
-
resultCallback: function() {},
|
234
|
-
queueRunnerFactory: function(attrs) {
|
235
|
-
spec.result.status = 'failed';
|
236
|
-
attrs.onComplete();
|
237
|
-
}
|
238
|
-
});
|
239
|
-
|
240
|
-
spec.execute(done);
|
241
|
-
|
242
|
-
expect(done).toHaveBeenCalledWith(jasmine.any(jasmineUnderTest.StopExecutionError));
|
243
|
-
});
|
244
|
-
|
245
|
-
it("#status returns passing by default", function() {
|
246
|
-
var spec = new jasmineUnderTest.Spec({queueableFn: { fn: jasmine.createSpy("spec body")} });
|
247
|
-
expect(spec.status()).toBe('passed');
|
248
|
-
});
|
249
|
-
|
250
|
-
it("#status returns passed if all expectations in the spec have passed", function() {
|
251
|
-
var spec = new jasmineUnderTest.Spec({queueableFn: { fn: jasmine.createSpy("spec body")} });
|
252
|
-
spec.addExpectationResult(true);
|
253
|
-
expect(spec.status()).toBe('passed');
|
254
|
-
});
|
255
|
-
|
256
|
-
it("#status returns failed if any expectations in the spec have failed", function() {
|
257
|
-
var spec = new jasmineUnderTest.Spec({queueableFn: { fn: jasmine.createSpy("spec body") } });
|
258
|
-
spec.addExpectationResult(true);
|
259
|
-
spec.addExpectationResult(false);
|
260
|
-
expect(spec.status()).toBe('failed');
|
261
|
-
});
|
262
|
-
|
263
|
-
it("keeps track of passed and failed expectations", function() {
|
264
|
-
var fakeQueueRunner = jasmine.createSpy('queueRunner'),
|
265
|
-
resultCallback = jasmine.createSpy('resultCallback'),
|
266
|
-
spec = new jasmineUnderTest.Spec({
|
267
|
-
queueableFn: { fn: jasmine.createSpy("spec body") },
|
268
|
-
expectationResultFactory: function (data) { return data; },
|
269
|
-
queueRunnerFactory: fakeQueueRunner,
|
270
|
-
resultCallback: resultCallback
|
271
|
-
});
|
272
|
-
spec.addExpectationResult(true, 'expectation1');
|
273
|
-
spec.addExpectationResult(false, 'expectation2');
|
274
|
-
|
275
|
-
spec.execute();
|
276
|
-
|
277
|
-
fakeQueueRunner.calls.mostRecent().args[0].cleanupFns[0].fn();
|
278
|
-
expect(resultCallback.calls.first().args[0].passedExpectations).toEqual(['expectation1']);
|
279
|
-
expect(resultCallback.calls.first().args[0].failedExpectations).toEqual(['expectation2']);
|
280
|
-
});
|
281
|
-
|
282
|
-
it("throws an ExpectationFailed error upon receiving a failed expectation when 'throwOnExpectationFailure' is set", function() {
|
283
|
-
var fakeQueueRunner = jasmine.createSpy('queueRunner'),
|
284
|
-
resultCallback = jasmine.createSpy('resultCallback'),
|
285
|
-
spec = new jasmineUnderTest.Spec({
|
286
|
-
queueableFn: { fn: function() {} },
|
287
|
-
expectationResultFactory: function(data) { return data; },
|
288
|
-
queueRunnerFactory: fakeQueueRunner,
|
289
|
-
resultCallback: resultCallback,
|
290
|
-
throwOnExpectationFailure: true
|
291
|
-
});
|
292
|
-
|
293
|
-
spec.addExpectationResult(true, 'passed');
|
294
|
-
expect(function() {
|
295
|
-
spec.addExpectationResult(false, 'failed')
|
296
|
-
}).toThrowError(jasmineUnderTest.errors.ExpectationFailed);
|
297
|
-
|
298
|
-
spec.execute();
|
299
|
-
|
300
|
-
fakeQueueRunner.calls.mostRecent().args[0].cleanupFns[0].fn();
|
301
|
-
expect(resultCallback.calls.first().args[0].passedExpectations).toEqual(['passed']);
|
302
|
-
expect(resultCallback.calls.first().args[0].failedExpectations).toEqual(['failed']);
|
303
|
-
});
|
304
|
-
|
305
|
-
it("does not throw an ExpectationFailed error when handling an error", function() {
|
306
|
-
var resultCallback = jasmine.createSpy('resultCallback'),
|
307
|
-
spec = new jasmineUnderTest.Spec({
|
308
|
-
queueableFn: { fn: function() {} },
|
309
|
-
expectationResultFactory: function(data) { return data; },
|
310
|
-
queueRunnerFactory: function(attrs) { attrs.onComplete(); },
|
311
|
-
resultCallback: resultCallback,
|
312
|
-
throwOnExpectationFailure: true
|
313
|
-
});
|
314
|
-
|
315
|
-
spec.onException('failing exception');
|
316
|
-
});
|
317
|
-
|
318
|
-
it("can return its full name", function() {
|
319
|
-
var specNameSpy = jasmine.createSpy('specNameSpy').and.returnValue('expected val');
|
320
|
-
|
321
|
-
var spec = new jasmineUnderTest.Spec({
|
322
|
-
getSpecName: specNameSpy,
|
323
|
-
queueableFn: { fn: null }
|
324
|
-
});
|
325
|
-
|
326
|
-
expect(spec.getFullName()).toBe('expected val');
|
327
|
-
expect(specNameSpy.calls.mostRecent().args[0].id).toEqual(spec.id);
|
328
|
-
});
|
329
|
-
|
330
|
-
describe("when a spec is marked pending during execution", function() {
|
331
|
-
it("should mark the spec as pending", function() {
|
332
|
-
var fakeQueueRunner = function(opts) {
|
333
|
-
opts.onException(new Error(jasmineUnderTest.Spec.pendingSpecExceptionMessage));
|
334
|
-
},
|
335
|
-
spec = new jasmineUnderTest.Spec({
|
336
|
-
description: 'my test',
|
337
|
-
id: 'some-id',
|
338
|
-
queueableFn: { fn: function() { } },
|
339
|
-
queueRunnerFactory: fakeQueueRunner
|
340
|
-
});
|
341
|
-
|
342
|
-
spec.execute();
|
343
|
-
|
344
|
-
expect(spec.status()).toEqual("pending");
|
345
|
-
expect(spec.result.pendingReason).toEqual('');
|
346
|
-
});
|
347
|
-
|
348
|
-
it("should set the pendingReason", function() {
|
349
|
-
var fakeQueueRunner = function(opts) {
|
350
|
-
opts.onException(new Error(jasmineUnderTest.Spec.pendingSpecExceptionMessage + 'custom message'));
|
351
|
-
},
|
352
|
-
spec = new jasmineUnderTest.Spec({
|
353
|
-
description: 'my test',
|
354
|
-
id: 'some-id',
|
355
|
-
queueableFn: { fn: function() { } },
|
356
|
-
queueRunnerFactory: fakeQueueRunner
|
357
|
-
});
|
358
|
-
|
359
|
-
spec.execute();
|
360
|
-
|
361
|
-
expect(spec.status()).toEqual("pending");
|
362
|
-
expect(spec.result.pendingReason).toEqual('custom message');
|
363
|
-
});
|
364
|
-
});
|
365
|
-
|
366
|
-
it("should log a failure when handling an exception", function() {
|
367
|
-
var fakeQueueRunner = jasmine.createSpy('queueRunner'),
|
368
|
-
resultCallback = jasmine.createSpy('resultCallback'),
|
369
|
-
spec = new jasmineUnderTest.Spec({
|
370
|
-
queueableFn: { fn: function() {} },
|
371
|
-
expectationResultFactory: function(data) { return data; },
|
372
|
-
queueRunnerFactory: fakeQueueRunner,
|
373
|
-
resultCallback: resultCallback
|
374
|
-
});
|
375
|
-
|
376
|
-
spec.onException('foo');
|
377
|
-
spec.execute();
|
378
|
-
|
379
|
-
var args = fakeQueueRunner.calls.mostRecent().args[0];
|
380
|
-
args.cleanupFns[0].fn();
|
381
|
-
expect(resultCallback.calls.first().args[0].failedExpectations).toEqual([{
|
382
|
-
error: 'foo',
|
383
|
-
matcherName: '',
|
384
|
-
passed: false,
|
385
|
-
expected: '',
|
386
|
-
actual: ''
|
387
|
-
}]);
|
388
|
-
});
|
389
|
-
|
390
|
-
it("should not log an additional failure when handling an ExpectationFailed error", function() {
|
391
|
-
var fakeQueueRunner = jasmine.createSpy('queueRunner'),
|
392
|
-
resultCallback = jasmine.createSpy('resultCallback'),
|
393
|
-
spec = new jasmineUnderTest.Spec({
|
394
|
-
queueableFn: { fn: function() {} },
|
395
|
-
expectationResultFactory: function(data) { return data; },
|
396
|
-
queueRunnerFactory: fakeQueueRunner,
|
397
|
-
resultCallback: resultCallback
|
398
|
-
});
|
399
|
-
|
400
|
-
spec.onException(new jasmineUnderTest.errors.ExpectationFailed());
|
401
|
-
spec.execute();
|
402
|
-
|
403
|
-
var args = fakeQueueRunner.calls.mostRecent().args[0];
|
404
|
-
args.cleanupFns[0].fn();
|
405
|
-
expect(resultCallback.calls.first().args[0].failedExpectations).toEqual([]);
|
406
|
-
});
|
407
|
-
});
|