jasmine-core 3.0.0 → 3.1.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/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,110 +0,0 @@
|
|
1
|
-
describe("GlobalErrors", function() {
|
2
|
-
it("calls the added handler on error", function() {
|
3
|
-
var fakeGlobal = { onerror: null },
|
4
|
-
handler = jasmine.createSpy('errorHandler'),
|
5
|
-
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal);
|
6
|
-
|
7
|
-
errors.install();
|
8
|
-
errors.pushListener(handler);
|
9
|
-
|
10
|
-
fakeGlobal.onerror('foo');
|
11
|
-
|
12
|
-
expect(handler).toHaveBeenCalledWith('foo');
|
13
|
-
});
|
14
|
-
|
15
|
-
it("only calls the most recent handler", function() {
|
16
|
-
var fakeGlobal = { onerror: null },
|
17
|
-
handler1 = jasmine.createSpy('errorHandler1'),
|
18
|
-
handler2 = jasmine.createSpy('errorHandler2'),
|
19
|
-
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal);
|
20
|
-
|
21
|
-
errors.install();
|
22
|
-
errors.pushListener(handler1);
|
23
|
-
errors.pushListener(handler2);
|
24
|
-
|
25
|
-
fakeGlobal.onerror('foo');
|
26
|
-
|
27
|
-
expect(handler1).not.toHaveBeenCalled();
|
28
|
-
expect(handler2).toHaveBeenCalledWith('foo');
|
29
|
-
});
|
30
|
-
|
31
|
-
it("calls previous handlers when one is removed", function() {
|
32
|
-
var fakeGlobal = { onerror: null },
|
33
|
-
handler1 = jasmine.createSpy('errorHandler1'),
|
34
|
-
handler2 = jasmine.createSpy('errorHandler2'),
|
35
|
-
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal);
|
36
|
-
|
37
|
-
errors.install();
|
38
|
-
errors.pushListener(handler1);
|
39
|
-
errors.pushListener(handler2);
|
40
|
-
|
41
|
-
errors.popListener();
|
42
|
-
|
43
|
-
fakeGlobal.onerror('foo');
|
44
|
-
|
45
|
-
expect(handler1).toHaveBeenCalledWith('foo');
|
46
|
-
expect(handler2).not.toHaveBeenCalled();
|
47
|
-
});
|
48
|
-
|
49
|
-
it("uninstalls itself, putting back a previous callback", function() {
|
50
|
-
var originalCallback = jasmine.createSpy('error'),
|
51
|
-
fakeGlobal = { onerror: originalCallback },
|
52
|
-
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal);
|
53
|
-
|
54
|
-
expect(fakeGlobal.onerror).toBe(originalCallback);
|
55
|
-
|
56
|
-
errors.install();
|
57
|
-
|
58
|
-
expect(fakeGlobal.onerror).not.toBe(originalCallback);
|
59
|
-
|
60
|
-
errors.uninstall();
|
61
|
-
|
62
|
-
expect(fakeGlobal.onerror).toBe(originalCallback);
|
63
|
-
});
|
64
|
-
|
65
|
-
it("rethrows the original error when there is no handler", function() {
|
66
|
-
var fakeGlobal = { },
|
67
|
-
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal),
|
68
|
-
originalError = new Error('nope');
|
69
|
-
|
70
|
-
errors.install();
|
71
|
-
|
72
|
-
try {
|
73
|
-
fakeGlobal.onerror(originalError);
|
74
|
-
} catch (e) {
|
75
|
-
expect(e).toBe(originalError);
|
76
|
-
}
|
77
|
-
|
78
|
-
errors.uninstall();
|
79
|
-
});
|
80
|
-
|
81
|
-
it("works in node.js", function() {
|
82
|
-
var fakeGlobal = {
|
83
|
-
process: {
|
84
|
-
on: jasmine.createSpy('process.on'),
|
85
|
-
removeListener: jasmine.createSpy('process.removeListener'),
|
86
|
-
listeners: jasmine.createSpy('process.listeners').and.returnValue(['foo']),
|
87
|
-
removeAllListeners: jasmine.createSpy('process.removeAllListeners')
|
88
|
-
}
|
89
|
-
},
|
90
|
-
handler = jasmine.createSpy('errorHandler'),
|
91
|
-
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal);
|
92
|
-
|
93
|
-
errors.install();
|
94
|
-
expect(fakeGlobal.process.on).toHaveBeenCalledWith('uncaughtException', jasmine.any(Function));
|
95
|
-
expect(fakeGlobal.process.listeners).toHaveBeenCalledWith('uncaughtException');
|
96
|
-
expect(fakeGlobal.process.removeAllListeners).toHaveBeenCalledWith('uncaughtException');
|
97
|
-
|
98
|
-
errors.pushListener(handler);
|
99
|
-
|
100
|
-
var addedListener = fakeGlobal.process.on.calls.argsFor(0)[1];
|
101
|
-
addedListener(new Error('bar'));
|
102
|
-
|
103
|
-
expect(handler).toHaveBeenCalledWith(new Error('bar'));
|
104
|
-
|
105
|
-
errors.uninstall();
|
106
|
-
|
107
|
-
expect(fakeGlobal.process.removeListener).toHaveBeenCalledWith('uncaughtException', addedListener);
|
108
|
-
expect(fakeGlobal.process.on).toHaveBeenCalledWith('uncaughtException', 'foo');
|
109
|
-
});
|
110
|
-
});
|
@@ -1,259 +0,0 @@
|
|
1
|
-
xdescribe('JsApiReporter (integration specs)', function() {
|
2
|
-
describe('results', function() {
|
3
|
-
var reporter, spec1, spec2;
|
4
|
-
var env;
|
5
|
-
var suite, nestedSuite, nestedSpec;
|
6
|
-
|
7
|
-
beforeEach(function() {
|
8
|
-
env = new jasmineUnderTest.Env();
|
9
|
-
|
10
|
-
suite = env.describe("top-level suite", function() {
|
11
|
-
spec1 = env.it("spec 1", function() {
|
12
|
-
this.expect(true).toEqual(true);
|
13
|
-
|
14
|
-
});
|
15
|
-
|
16
|
-
spec2 = env.it("spec 2", function() {
|
17
|
-
this.expect(true).toEqual(false);
|
18
|
-
});
|
19
|
-
|
20
|
-
nestedSuite = env.describe("nested suite", function() {
|
21
|
-
nestedSpec = env.it("nested spec", function() {
|
22
|
-
expect(true).toEqual(true);
|
23
|
-
});
|
24
|
-
});
|
25
|
-
|
26
|
-
});
|
27
|
-
|
28
|
-
reporter = new jasmineUnderTest.JsApiReporter({});
|
29
|
-
env.addReporter(reporter);
|
30
|
-
|
31
|
-
env.execute();
|
32
|
-
|
33
|
-
});
|
34
|
-
|
35
|
-
it('results() should return a hash of all results, indexed by spec id', function() {
|
36
|
-
var expectedSpec1Results = {
|
37
|
-
result: "passed"
|
38
|
-
},
|
39
|
-
expectedSpec2Results = {
|
40
|
-
result: "failed"
|
41
|
-
};
|
42
|
-
expect(reporter.results()[spec1.id].result).toEqual('passed');
|
43
|
-
expect(reporter.results()[spec2.id].result).toEqual('failed');
|
44
|
-
});
|
45
|
-
|
46
|
-
it("should return nested suites as children of their parents", function() {
|
47
|
-
expect(reporter.suites()).toEqual([
|
48
|
-
{ id: 0, name: 'top-level suite', type: 'suite',
|
49
|
-
children: [
|
50
|
-
{ id: 0, name: 'spec 1', type: 'spec', children: [ ] },
|
51
|
-
{ id: 1, name: 'spec 2', type: 'spec', children: [ ] },
|
52
|
-
{ id: 1, name: 'nested suite', type: 'suite',
|
53
|
-
children: [
|
54
|
-
{ id: 2, name: 'nested spec', type: 'spec', children: [ ] }
|
55
|
-
]
|
56
|
-
},
|
57
|
-
]
|
58
|
-
}
|
59
|
-
]);
|
60
|
-
});
|
61
|
-
|
62
|
-
describe("#summarizeResult_", function() {
|
63
|
-
it("should summarize a passing result", function() {
|
64
|
-
var result = reporter.results()[spec1.id];
|
65
|
-
var summarizedResult = reporter.summarizeResult_(result);
|
66
|
-
expect(summarizedResult.result).toEqual('passed');
|
67
|
-
expect(summarizedResult.messages.length).toEqual(0);
|
68
|
-
});
|
69
|
-
|
70
|
-
it("should have a stack trace for failing specs", function() {
|
71
|
-
var result = reporter.results()[spec2.id];
|
72
|
-
var summarizedResult = reporter.summarizeResult_(result);
|
73
|
-
expect(summarizedResult.result).toEqual('failed');
|
74
|
-
expect(summarizedResult.messages[0].trace.stack).toEqual(result.messages[0].trace.stack);
|
75
|
-
});
|
76
|
-
|
77
|
-
});
|
78
|
-
});
|
79
|
-
});
|
80
|
-
|
81
|
-
|
82
|
-
describe("JsApiReporter", function() {
|
83
|
-
|
84
|
-
it("knows when a full environment is started", function() {
|
85
|
-
var reporter = new jasmineUnderTest.JsApiReporter({});
|
86
|
-
|
87
|
-
expect(reporter.started).toBe(false);
|
88
|
-
expect(reporter.finished).toBe(false);
|
89
|
-
|
90
|
-
reporter.jasmineStarted();
|
91
|
-
|
92
|
-
expect(reporter.started).toBe(true);
|
93
|
-
expect(reporter.finished).toBe(false);
|
94
|
-
});
|
95
|
-
|
96
|
-
it("knows when a full environment is done", function() {
|
97
|
-
var reporter = new jasmineUnderTest.JsApiReporter({});
|
98
|
-
|
99
|
-
expect(reporter.started).toBe(false);
|
100
|
-
expect(reporter.finished).toBe(false);
|
101
|
-
|
102
|
-
reporter.jasmineStarted();
|
103
|
-
reporter.jasmineDone({});
|
104
|
-
|
105
|
-
expect(reporter.finished).toBe(true);
|
106
|
-
});
|
107
|
-
|
108
|
-
it("defaults to 'loaded' status", function() {
|
109
|
-
var reporter = new jasmineUnderTest.JsApiReporter({});
|
110
|
-
|
111
|
-
expect(reporter.status()).toEqual('loaded');
|
112
|
-
});
|
113
|
-
|
114
|
-
it("reports 'started' when Jasmine has started", function() {
|
115
|
-
var reporter = new jasmineUnderTest.JsApiReporter({});
|
116
|
-
|
117
|
-
reporter.jasmineStarted();
|
118
|
-
|
119
|
-
expect(reporter.status()).toEqual('started');
|
120
|
-
});
|
121
|
-
|
122
|
-
it("reports 'done' when Jasmine is done", function() {
|
123
|
-
var reporter = new jasmineUnderTest.JsApiReporter({});
|
124
|
-
|
125
|
-
reporter.jasmineDone({});
|
126
|
-
|
127
|
-
expect(reporter.status()).toEqual('done');
|
128
|
-
});
|
129
|
-
|
130
|
-
it("tracks a suite", function() {
|
131
|
-
var reporter = new jasmineUnderTest.JsApiReporter({});
|
132
|
-
|
133
|
-
reporter.suiteStarted({
|
134
|
-
id: 123,
|
135
|
-
description: "A suite"
|
136
|
-
});
|
137
|
-
|
138
|
-
var suites = reporter.suites();
|
139
|
-
|
140
|
-
expect(suites).toEqual({123: {id: 123, description: "A suite"}});
|
141
|
-
|
142
|
-
reporter.suiteDone({
|
143
|
-
id: 123,
|
144
|
-
description: "A suite",
|
145
|
-
status: 'passed'
|
146
|
-
});
|
147
|
-
|
148
|
-
expect(suites).toEqual({123: {id: 123, description: "A suite", status: 'passed'}});
|
149
|
-
});
|
150
|
-
|
151
|
-
describe("#specResults", function() {
|
152
|
-
var reporter, specResult1, specResult2;
|
153
|
-
beforeEach(function() {
|
154
|
-
reporter = new jasmineUnderTest.JsApiReporter({});
|
155
|
-
specResult1 = {
|
156
|
-
id: 1,
|
157
|
-
description: "A spec"
|
158
|
-
};
|
159
|
-
specResult2 = {
|
160
|
-
id: 2,
|
161
|
-
description: "Another spec"
|
162
|
-
};
|
163
|
-
|
164
|
-
reporter.specDone(specResult1);
|
165
|
-
reporter.specDone(specResult2);
|
166
|
-
});
|
167
|
-
|
168
|
-
it("should return a slice of results", function() {
|
169
|
-
expect(reporter.specResults(0, 1)).toEqual([specResult1]);
|
170
|
-
expect(reporter.specResults(1, 1)).toEqual([specResult2]);
|
171
|
-
});
|
172
|
-
|
173
|
-
describe("when the results do not exist", function() {
|
174
|
-
it("should return a slice of shorter length", function() {
|
175
|
-
expect(reporter.specResults(0, 3)).toEqual([specResult1, specResult2]);
|
176
|
-
expect(reporter.specResults(2, 3)).toEqual([]);
|
177
|
-
});
|
178
|
-
});
|
179
|
-
});
|
180
|
-
|
181
|
-
describe("#suiteResults", function(){
|
182
|
-
var reporter, suiteResult1, suiteResult2;
|
183
|
-
beforeEach(function() {
|
184
|
-
reporter = new jasmineUnderTest.JsApiReporter({});
|
185
|
-
suiteStarted1 = {
|
186
|
-
id: 1
|
187
|
-
};
|
188
|
-
suiteResult1 = {
|
189
|
-
id: 1,
|
190
|
-
status: 'failed',
|
191
|
-
failedExpectations: [{ message: 'My After All Exception' }]
|
192
|
-
};
|
193
|
-
suiteResult2 = {
|
194
|
-
id: 2,
|
195
|
-
status: 'passed'
|
196
|
-
};
|
197
|
-
|
198
|
-
reporter.suiteStarted(suiteStarted1);
|
199
|
-
reporter.suiteDone(suiteResult1);
|
200
|
-
reporter.suiteDone(suiteResult2);
|
201
|
-
});
|
202
|
-
|
203
|
-
it('should not include suite starts', function(){
|
204
|
-
expect(reporter.suiteResults(0,3).length).toEqual(2);
|
205
|
-
});
|
206
|
-
|
207
|
-
it("should return a slice of results", function() {
|
208
|
-
expect(reporter.suiteResults(0, 1)).toEqual([suiteResult1]);
|
209
|
-
expect(reporter.suiteResults(1, 1)).toEqual([suiteResult2]);
|
210
|
-
});
|
211
|
-
|
212
|
-
it("returns nothing for out of bounds indicies", function() {
|
213
|
-
expect(reporter.suiteResults(0, 3)).toEqual([suiteResult1, suiteResult2]);
|
214
|
-
expect(reporter.suiteResults(2, 3)).toEqual([]);
|
215
|
-
});
|
216
|
-
});
|
217
|
-
|
218
|
-
describe("#executionTime", function() {
|
219
|
-
it("should start the timer when jasmine starts", function() {
|
220
|
-
var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
221
|
-
reporter = new jasmineUnderTest.JsApiReporter({
|
222
|
-
timer: timerSpy
|
223
|
-
});
|
224
|
-
|
225
|
-
reporter.jasmineStarted();
|
226
|
-
expect(timerSpy.start).toHaveBeenCalled();
|
227
|
-
});
|
228
|
-
|
229
|
-
it("should return the time it took the specs to run, in ms", function() {
|
230
|
-
var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
231
|
-
reporter = new jasmineUnderTest.JsApiReporter({
|
232
|
-
timer: timerSpy
|
233
|
-
});
|
234
|
-
|
235
|
-
timerSpy.elapsed.and.returnValue(1000);
|
236
|
-
reporter.jasmineDone();
|
237
|
-
expect(reporter.executionTime()).toEqual(1000);
|
238
|
-
});
|
239
|
-
|
240
|
-
describe("when the specs haven't finished being run", function() {
|
241
|
-
it("should return undefined", function() {
|
242
|
-
var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
243
|
-
reporter = new jasmineUnderTest.JsApiReporter({
|
244
|
-
timer: timerSpy
|
245
|
-
});
|
246
|
-
|
247
|
-
expect(reporter.executionTime()).toBeUndefined();
|
248
|
-
});
|
249
|
-
});
|
250
|
-
});
|
251
|
-
|
252
|
-
describe('#runDetails', function() {
|
253
|
-
it('should have details about the run', function() {
|
254
|
-
var reporter = new jasmineUnderTest.JsApiReporter({});
|
255
|
-
reporter.jasmineDone({some: {run: 'details'}});
|
256
|
-
expect(reporter.runDetails).toEqual({some: {run: 'details'}});
|
257
|
-
});
|
258
|
-
});
|
259
|
-
});
|
@@ -1,200 +0,0 @@
|
|
1
|
-
describe("FakeDate", function() {
|
2
|
-
it("does not fail if no global date is found", function() {
|
3
|
-
var fakeGlobal = {},
|
4
|
-
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
5
|
-
|
6
|
-
expect(function() {
|
7
|
-
mockDate.install();
|
8
|
-
mockDate.tick(0);
|
9
|
-
mockDate.uninstall();
|
10
|
-
}).not.toThrow();
|
11
|
-
});
|
12
|
-
|
13
|
-
it("replaces the global Date when it is installed", function() {
|
14
|
-
var globalDate = jasmine.createSpy("global Date").and.callFake(function() {
|
15
|
-
return {
|
16
|
-
getTime: function() {}
|
17
|
-
}
|
18
|
-
}),
|
19
|
-
fakeGlobal = { Date: globalDate },
|
20
|
-
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
21
|
-
|
22
|
-
expect(fakeGlobal.Date).toEqual(globalDate);
|
23
|
-
mockDate.install();
|
24
|
-
|
25
|
-
expect(fakeGlobal.Date).not.toEqual(globalDate);
|
26
|
-
});
|
27
|
-
|
28
|
-
it("replaces the global Date on uninstall", function() {
|
29
|
-
var globalDate = jasmine.createSpy("global Date").and.callFake(function() {
|
30
|
-
return {
|
31
|
-
getTime: function() {}
|
32
|
-
}
|
33
|
-
}),
|
34
|
-
fakeGlobal = { Date: globalDate },
|
35
|
-
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
36
|
-
|
37
|
-
mockDate.install();
|
38
|
-
mockDate.uninstall();
|
39
|
-
|
40
|
-
expect(fakeGlobal.Date).toEqual(globalDate);
|
41
|
-
});
|
42
|
-
|
43
|
-
it("takes the current time as the base when installing without parameters", function() {
|
44
|
-
var globalDate = jasmine.createSpy("global Date").and.callFake(function() {
|
45
|
-
return {
|
46
|
-
getTime: function() {
|
47
|
-
return 1000;
|
48
|
-
}
|
49
|
-
}
|
50
|
-
}),
|
51
|
-
fakeGlobal = { Date: globalDate },
|
52
|
-
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
53
|
-
|
54
|
-
mockDate.install();
|
55
|
-
|
56
|
-
globalDate.calls.reset();
|
57
|
-
new fakeGlobal.Date();
|
58
|
-
expect(globalDate).toHaveBeenCalledWith(1000);
|
59
|
-
});
|
60
|
-
|
61
|
-
it("can accept a date as time base when installing", function() {
|
62
|
-
var fakeGlobal = { Date: Date },
|
63
|
-
mockDate = new jasmineUnderTest.MockDate(fakeGlobal),
|
64
|
-
baseDate = new Date();
|
65
|
-
|
66
|
-
spyOn(baseDate, 'getTime').and.returnValue(123);
|
67
|
-
mockDate.install(baseDate);
|
68
|
-
|
69
|
-
expect(new fakeGlobal.Date().getTime()).toEqual(123);
|
70
|
-
});
|
71
|
-
|
72
|
-
it("makes real dates", function() {
|
73
|
-
var fakeGlobal = { Date: Date },
|
74
|
-
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
75
|
-
|
76
|
-
mockDate.install();
|
77
|
-
expect(new fakeGlobal.Date()).toEqual(jasmine.any(Date));
|
78
|
-
expect(new fakeGlobal.Date() instanceof fakeGlobal.Date).toBe(true);
|
79
|
-
});
|
80
|
-
|
81
|
-
it("fakes current time when using Date.now()", function() {
|
82
|
-
var globalDate = jasmine.createSpy("global Date").and.callFake(function() {
|
83
|
-
return {
|
84
|
-
getTime: function() {
|
85
|
-
return 1000;
|
86
|
-
}
|
87
|
-
}
|
88
|
-
}),
|
89
|
-
fakeGlobal = { Date: globalDate };
|
90
|
-
|
91
|
-
globalDate.now = function() {};
|
92
|
-
var mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
93
|
-
|
94
|
-
mockDate.install();
|
95
|
-
|
96
|
-
expect(fakeGlobal.Date.now()).toEqual(1000);
|
97
|
-
});
|
98
|
-
|
99
|
-
it("does not stub Date.now() if it doesn't already exist", function() {
|
100
|
-
var globalDate = jasmine.createSpy("global Date").and.callFake(function() {
|
101
|
-
return {
|
102
|
-
getTime: function() {
|
103
|
-
return 1000;
|
104
|
-
}
|
105
|
-
}
|
106
|
-
}),
|
107
|
-
fakeGlobal = { Date: globalDate },
|
108
|
-
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
109
|
-
|
110
|
-
mockDate.install();
|
111
|
-
|
112
|
-
expect(fakeGlobal.Date.now).toThrowError("Browser does not support Date.now()");
|
113
|
-
});
|
114
|
-
|
115
|
-
it("makes time passes using tick", function() {
|
116
|
-
var globalDate = jasmine.createSpy("global Date").and.callFake(function() {
|
117
|
-
return {
|
118
|
-
getTime: function() {
|
119
|
-
return 1000;
|
120
|
-
}
|
121
|
-
}
|
122
|
-
}),
|
123
|
-
fakeGlobal = { Date: globalDate };
|
124
|
-
|
125
|
-
globalDate.now = function() {};
|
126
|
-
var mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
127
|
-
|
128
|
-
mockDate.install();
|
129
|
-
|
130
|
-
mockDate.tick(100);
|
131
|
-
|
132
|
-
expect(fakeGlobal.Date.now()).toEqual(1100);
|
133
|
-
|
134
|
-
mockDate.tick(1000);
|
135
|
-
|
136
|
-
expect(fakeGlobal.Date.now()).toEqual(2100);
|
137
|
-
});
|
138
|
-
|
139
|
-
it("allows to increase 0 milliseconds using tick", function() {
|
140
|
-
var globalDate = jasmine.createSpy("global Date").and.callFake(function() {
|
141
|
-
return {
|
142
|
-
getTime: function() {
|
143
|
-
return 1000;
|
144
|
-
}
|
145
|
-
}
|
146
|
-
}),
|
147
|
-
fakeGlobal = { Date: globalDate };
|
148
|
-
|
149
|
-
globalDate.now = function() {};
|
150
|
-
var mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
151
|
-
|
152
|
-
mockDate.install();
|
153
|
-
|
154
|
-
mockDate.tick(0);
|
155
|
-
expect(fakeGlobal.Date.now()).toEqual(1000);
|
156
|
-
|
157
|
-
mockDate.tick();
|
158
|
-
expect(fakeGlobal.Date.now()).toEqual(1000);
|
159
|
-
});
|
160
|
-
|
161
|
-
it("allows creation of a Date in a different time than the mocked time", function() {
|
162
|
-
var fakeGlobal = { Date: Date },
|
163
|
-
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
164
|
-
|
165
|
-
mockDate.install();
|
166
|
-
|
167
|
-
var otherDate = new fakeGlobal.Date(2013, 9, 23, 0, 0, 1, 0);
|
168
|
-
expect(otherDate.getTime()).toEqual(new Date(2013, 9, 23, 0, 0, 1, 0).getTime());
|
169
|
-
});
|
170
|
-
|
171
|
-
it("allows creation of a Date that isn't fully specified", function() {
|
172
|
-
var fakeGlobal = { Date: Date },
|
173
|
-
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
174
|
-
|
175
|
-
mockDate.install();
|
176
|
-
|
177
|
-
var otherDate = new fakeGlobal.Date(2013, 9, 23);
|
178
|
-
expect(otherDate.getTime()).toEqual(new Date(2013, 9, 23).getTime());
|
179
|
-
});
|
180
|
-
|
181
|
-
it('allows creation of a Date with millis', function() {
|
182
|
-
var fakeGlobal = { Date: Date },
|
183
|
-
mockDate = new jasmineUnderTest.MockDate(fakeGlobal),
|
184
|
-
now = new Date(2014, 3, 15).getTime();
|
185
|
-
|
186
|
-
mockDate.install();
|
187
|
-
|
188
|
-
var otherDate = new fakeGlobal.Date(now);
|
189
|
-
expect(otherDate.getTime()).toEqual(now);
|
190
|
-
});
|
191
|
-
|
192
|
-
it("copies all Date properties to the mocked date", function() {
|
193
|
-
var fakeGlobal = { Date: Date },
|
194
|
-
mockDate = new jasmineUnderTest.MockDate(fakeGlobal);
|
195
|
-
|
196
|
-
mockDate.install();
|
197
|
-
|
198
|
-
expect(fakeGlobal.Date.UTC(2013, 9, 23)).toEqual(Date.UTC(2013, 9, 23));
|
199
|
-
});
|
200
|
-
});
|