jasmine-core 2.0.0 → 2.1.1
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 +54 -24
- data/lib/jasmine-core/__init__.py +1 -0
- data/lib/jasmine-core/boot/boot.js +2 -63
- data/lib/jasmine-core/boot/node_boot.js +19 -0
- data/lib/jasmine-core/boot.js +3 -64
- data/lib/jasmine-core/core.py +60 -0
- data/lib/jasmine-core/example/node_example/spec/PlayerSpec.js +60 -0
- data/lib/jasmine-core/example/node_example/spec/SpecHelper.js +15 -0
- data/lib/jasmine-core/example/node_example/src/Player.js +24 -0
- data/lib/jasmine-core/example/node_example/src/Song.js +9 -0
- data/lib/jasmine-core/jasmine-html.js +119 -74
- data/lib/jasmine-core/jasmine.css +61 -54
- data/lib/jasmine-core/jasmine.js +964 -456
- data/lib/jasmine-core/json2.js +73 -62
- data/lib/jasmine-core/node_boot.js +41 -0
- data/lib/jasmine-core/spec/console/ConsoleReporterSpec.js +52 -8
- data/lib/jasmine-core/spec/core/AnySpec.js +1 -0
- data/lib/jasmine-core/spec/core/ClockSpec.js +122 -18
- data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +14 -1
- data/lib/jasmine-core/spec/core/EnvSpec.js +0 -63
- data/lib/jasmine-core/spec/core/ExceptionFormatterSpec.js +7 -0
- data/lib/jasmine-core/spec/core/ExceptionsSpec.js +2 -2
- data/lib/jasmine-core/spec/core/ExpectationSpec.js +46 -50
- data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +37 -0
- data/lib/jasmine-core/spec/core/MockDateSpec.js +200 -0
- data/lib/jasmine-core/spec/core/ObjectContainingSpec.js +6 -0
- data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +49 -12
- data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +184 -60
- data/lib/jasmine-core/spec/core/SpecSpec.js +46 -108
- data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +55 -0
- data/lib/jasmine-core/spec/core/SpySpec.js +10 -0
- data/lib/jasmine-core/spec/core/SpyStrategySpec.js +13 -0
- data/lib/jasmine-core/spec/core/SuiteSpec.js +143 -11
- data/lib/jasmine-core/spec/core/TimerSpec.js +18 -0
- data/lib/jasmine-core/spec/core/integration/CustomMatchersSpec.js +34 -32
- data/lib/jasmine-core/spec/core/integration/EnvSpec.js +998 -50
- data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +279 -3
- data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +18 -1
- data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanSpec.js +2 -1
- data/lib/jasmine-core/spec/core/matchers/toBeNaNSpec.js +3 -2
- data/lib/jasmine-core/spec/core/matchers/toBeUndefinedSpec.js +2 -1
- data/lib/jasmine-core/spec/core/matchers/toContainSpec.js +4 -2
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js +2 -1
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledWithSpec.js +17 -3
- data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +14 -14
- data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +5 -5
- data/lib/jasmine-core/spec/helpers/defineJasmineUnderTest.js +7 -0
- data/lib/jasmine-core/spec/helpers/nodeDefineJasmineUnderTest.js +33 -0
- data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +183 -35
- data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +1 -1
- data/lib/jasmine-core/spec/node_suite.js +9 -1
- data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +104 -0
- data/lib/jasmine-core/spec/performance/large_object_test.js +36 -0
- data/lib/jasmine-core/version.rb +1 -1
- data/lib/jasmine-core.js +37 -0
- data/lib/jasmine-core.rb +6 -2
- metadata +23 -9
- data/lib/jasmine-core/spec/support/dev_boot.js +0 -124
@@ -13,7 +13,7 @@ describe("New HtmlReporter", function() {
|
|
13
13
|
reporter.initialize();
|
14
14
|
|
15
15
|
// Main top-level elements
|
16
|
-
expect(container.querySelector("div.
|
16
|
+
expect(container.querySelector("div.jasmine_html-reporter")).toBeTruthy();
|
17
17
|
expect(container.querySelector("div.banner")).toBeTruthy();
|
18
18
|
expect(container.querySelector("div.alert")).toBeTruthy();
|
19
19
|
expect(container.querySelector("div.results")).toBeTruthy();
|
@@ -23,18 +23,36 @@ describe("New HtmlReporter", function() {
|
|
23
23
|
// title banner
|
24
24
|
var banner = container.querySelector(".banner");
|
25
25
|
|
26
|
-
var title = banner.querySelector(".title");
|
27
|
-
expect(title.
|
26
|
+
var title = banner.querySelector("a.title");
|
27
|
+
expect(title.getAttribute('href')).toEqual('http://jasmine.github.io/');
|
28
|
+
expect(title.getAttribute('target')).toEqual('_blank');
|
28
29
|
|
29
30
|
var version = banner.querySelector(".version"),
|
30
31
|
versionText = 'textContent' in version ? version.textContent : version.innerText;
|
31
32
|
expect(versionText).toEqual(j$.version);
|
32
33
|
});
|
33
34
|
|
35
|
+
it("builds a single reporter even if initialized multiple times", function() {
|
36
|
+
var env = new j$.Env(),
|
37
|
+
container = document.createElement("div"),
|
38
|
+
getContainer = function() { return container; },
|
39
|
+
reporter = new j$.HtmlReporter({
|
40
|
+
env: env,
|
41
|
+
getContainer: getContainer,
|
42
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
43
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
44
|
+
});
|
45
|
+
reporter.initialize();
|
46
|
+
reporter.initialize();
|
47
|
+
reporter.initialize();
|
48
|
+
|
49
|
+
expect(container.querySelectorAll("div.jasmine_html-reporter").length).toEqual(1);
|
50
|
+
});
|
51
|
+
|
34
52
|
it("starts the timer when jasmine begins", function() {
|
35
53
|
var env = new jasmine.Env(),
|
36
54
|
startTimerSpy = jasmine.createSpy("start-timer-spy"),
|
37
|
-
reporter = new
|
55
|
+
reporter = new j$.HtmlReporter({
|
38
56
|
env: env,
|
39
57
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
40
58
|
timer: { start: startTimerSpy }
|
@@ -46,6 +64,36 @@ describe("New HtmlReporter", function() {
|
|
46
64
|
});
|
47
65
|
|
48
66
|
describe("when a spec is done", function() {
|
67
|
+
it("logs errors to the console and prints a special symbol if it is an empty spec", function() {
|
68
|
+
if (typeof console === "undefined") {
|
69
|
+
console = { error: function(){} };
|
70
|
+
}
|
71
|
+
|
72
|
+
var env = new j$.Env(),
|
73
|
+
container = document.createElement('div'),
|
74
|
+
getContainer = function() {return container;},
|
75
|
+
reporter = new j$.HtmlReporter({
|
76
|
+
env: env,
|
77
|
+
getContainer: getContainer,
|
78
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
79
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
80
|
+
});
|
81
|
+
|
82
|
+
spyOn(console, 'error');
|
83
|
+
|
84
|
+
reporter.initialize();
|
85
|
+
|
86
|
+
reporter.specDone({
|
87
|
+
status: "passed",
|
88
|
+
fullName: 'Some Name',
|
89
|
+
passedExpectations: [],
|
90
|
+
failedExpectations: []
|
91
|
+
});
|
92
|
+
expect(console.error).toHaveBeenCalledWith("Spec \'Some Name\' has no expectations.");
|
93
|
+
var specEl = container.querySelector('.symbol-summary li');
|
94
|
+
expect(specEl.getAttribute("class")).toEqual("empty");
|
95
|
+
});
|
96
|
+
|
49
97
|
it("reports the status symbol of a disabled spec", function() {
|
50
98
|
var env = new j$.Env(),
|
51
99
|
container = document.createElement("div"),
|
@@ -58,7 +106,7 @@ describe("New HtmlReporter", function() {
|
|
58
106
|
});
|
59
107
|
reporter.initialize();
|
60
108
|
|
61
|
-
reporter.specDone({id: 789, status: "disabled", fullName: "symbols should have titles"});
|
109
|
+
reporter.specDone({id: 789, status: "disabled", fullName: "symbols should have titles", passedExpectations: [], failedExpectations: []});
|
62
110
|
|
63
111
|
var specEl = container.querySelector('.symbol-summary li');
|
64
112
|
expect(specEl.getAttribute("class")).toEqual("disabled");
|
@@ -78,7 +126,7 @@ describe("New HtmlReporter", function() {
|
|
78
126
|
});
|
79
127
|
reporter.initialize();
|
80
128
|
|
81
|
-
reporter.specDone({id: 789, status: "pending"});
|
129
|
+
reporter.specDone({id: 789, status: "pending", passedExpectations: [], failedExpectations: []});
|
82
130
|
|
83
131
|
var specEl = container.querySelector('.symbol-summary li');
|
84
132
|
expect(specEl.getAttribute("class")).toEqual("pending");
|
@@ -97,7 +145,7 @@ describe("New HtmlReporter", function() {
|
|
97
145
|
});
|
98
146
|
reporter.initialize();
|
99
147
|
|
100
|
-
reporter.specDone({id: 123, status: "passed"});
|
148
|
+
reporter.specDone({id: 123, status: "passed", passedExpectations: [{passed: true}], failedExpectations: []});
|
101
149
|
|
102
150
|
var statuses = container.querySelector(".symbol-summary");
|
103
151
|
var specEl = statuses.querySelector("li");
|
@@ -121,7 +169,8 @@ describe("New HtmlReporter", function() {
|
|
121
169
|
reporter.specDone({
|
122
170
|
id: 345,
|
123
171
|
status: "failed",
|
124
|
-
failedExpectations: []
|
172
|
+
failedExpectations: [],
|
173
|
+
passedExpectations: []
|
125
174
|
});
|
126
175
|
|
127
176
|
var specEl = container.querySelector(".symbol-summary li");
|
@@ -130,7 +179,73 @@ describe("New HtmlReporter", function() {
|
|
130
179
|
});
|
131
180
|
});
|
132
181
|
|
182
|
+
describe("when there are suite failures", function () {
|
183
|
+
it("displays the exceptions in their own alert bars", function(){
|
184
|
+
var env = new j$.Env(),
|
185
|
+
container = document.createElement("div"),
|
186
|
+
getContainer = function() { return container; },
|
187
|
+
reporter = new j$.HtmlReporter({
|
188
|
+
env: env,
|
189
|
+
getContainer: getContainer,
|
190
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
191
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
192
|
+
});
|
193
|
+
|
194
|
+
reporter.initialize();
|
195
|
+
|
196
|
+
reporter.jasmineStarted({});
|
197
|
+
reporter.suiteDone({ status: 'failed', failedExpectations: [{ message: 'My After All Exception' }] });
|
198
|
+
reporter.suiteDone({ status: 'failed', failedExpectations: [{ message: 'My Other Exception' }] });
|
199
|
+
reporter.jasmineDone({});
|
200
|
+
|
201
|
+
var alertBars = container.querySelectorAll(".alert .bar");
|
202
|
+
|
203
|
+
expect(alertBars.length).toEqual(3);
|
204
|
+
expect(alertBars[1].innerHTML).toMatch(/My After All Exception/);
|
205
|
+
expect(alertBars[1].getAttribute("class")).toEqual('bar errored');
|
206
|
+
expect(alertBars[2].innerHTML).toMatch(/My Other Exception/);
|
207
|
+
});
|
208
|
+
});
|
209
|
+
|
133
210
|
describe("when Jasmine is done", function() {
|
211
|
+
it("adds EMPTY to the link title of specs that have no expectations", function() {
|
212
|
+
if (!window.console) {
|
213
|
+
window.console = { error: function(){} };
|
214
|
+
}
|
215
|
+
var env = new j$.Env(),
|
216
|
+
container = document.createElement('div'),
|
217
|
+
getContainer = function() {return container;},
|
218
|
+
reporter = new j$.HtmlReporter({
|
219
|
+
env: env,
|
220
|
+
getContainer: getContainer,
|
221
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
222
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
223
|
+
});
|
224
|
+
|
225
|
+
spyOn(console, 'error');
|
226
|
+
|
227
|
+
reporter.initialize();
|
228
|
+
reporter.jasmineStarted({});
|
229
|
+
reporter.suiteStarted({id: 1});
|
230
|
+
reporter.specStarted({id: 1, status: 'passed', passedExpectations: [], failedExpectations: []});
|
231
|
+
reporter.specDone({
|
232
|
+
id: 1,
|
233
|
+
status: 'passed',
|
234
|
+
description: 'Spec Description',
|
235
|
+
passedExpectations: [],
|
236
|
+
failedExpectations: []
|
237
|
+
});
|
238
|
+
reporter.suiteDone({id: 1});
|
239
|
+
reporter.jasmineDone({});
|
240
|
+
|
241
|
+
var summary = container.querySelector('.summary');
|
242
|
+
var suite = summary.childNodes[0];
|
243
|
+
var specs = suite.childNodes[1];
|
244
|
+
var spec = specs.childNodes[0];
|
245
|
+
var specLink = spec.childNodes[0];
|
246
|
+
expect(specLink.innerHTML).toMatch(/SPEC HAS NO EXPECTATIONS/);
|
247
|
+
});
|
248
|
+
|
134
249
|
it("reports the run time", function() {
|
135
250
|
var env = new j$.Env(),
|
136
251
|
container = document.createElement("div"),
|
@@ -178,7 +293,9 @@ describe("New HtmlReporter", function() {
|
|
178
293
|
id: 123,
|
179
294
|
description: "with a spec",
|
180
295
|
fullName: "A Suite with a spec",
|
181
|
-
status: "passed"
|
296
|
+
status: "passed",
|
297
|
+
failedExpectations: [],
|
298
|
+
passedExpectations: [{passed: true}]
|
182
299
|
};
|
183
300
|
reporter.specStarted(specResult);
|
184
301
|
reporter.specDone(specResult);
|
@@ -193,7 +310,9 @@ describe("New HtmlReporter", function() {
|
|
193
310
|
id: 124,
|
194
311
|
description: "with another spec",
|
195
312
|
fullName: "A Suite inner suite with another spec",
|
196
|
-
status: "passed"
|
313
|
+
status: "passed",
|
314
|
+
failedExpectations: [],
|
315
|
+
passedExpectations: [{passed: true}]
|
197
316
|
};
|
198
317
|
reporter.specStarted(specResult);
|
199
318
|
reporter.specDone(specResult);
|
@@ -205,7 +324,8 @@ describe("New HtmlReporter", function() {
|
|
205
324
|
description: "with a failing spec",
|
206
325
|
fullName: "A Suite inner with a failing spec",
|
207
326
|
status: "failed",
|
208
|
-
failedExpectations: []
|
327
|
+
failedExpectations: [{}],
|
328
|
+
passedExpectations: []
|
209
329
|
};
|
210
330
|
reporter.specStarted(specResult);
|
211
331
|
reporter.specDone(specResult);
|
@@ -321,12 +441,33 @@ describe("New HtmlReporter", function() {
|
|
321
441
|
});
|
322
442
|
});
|
323
443
|
|
444
|
+
it("shows a message if no specs are run", function(){
|
445
|
+
var env, container, reporter;
|
446
|
+
env = new j$.Env();
|
447
|
+
container = document.createElement("div");
|
448
|
+
var getContainer = function() { return container; },
|
449
|
+
reporter = new j$.HtmlReporter({
|
450
|
+
env: env,
|
451
|
+
getContainer: getContainer,
|
452
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
453
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
454
|
+
});
|
455
|
+
reporter.initialize();
|
456
|
+
|
457
|
+
reporter.jasmineStarted({});
|
458
|
+
reporter.jasmineDone({});
|
459
|
+
|
460
|
+
var alertBars = container.querySelectorAll(".alert .bar");
|
461
|
+
expect(alertBars[0].getAttribute('class')).toMatch(/skipped/);
|
462
|
+
expect(alertBars[0].innerHTML).toMatch(/No specs found/);
|
463
|
+
});
|
464
|
+
|
324
465
|
describe("and all specs pass", function() {
|
325
466
|
var env, container, reporter;
|
326
467
|
beforeEach(function() {
|
327
468
|
env = new j$.Env();
|
328
469
|
container = document.createElement("div");
|
329
|
-
getContainer = function() { return container; },
|
470
|
+
var getContainer = function() { return container; },
|
330
471
|
reporter = new j$.HtmlReporter({
|
331
472
|
env: env,
|
332
473
|
getContainer: getContainer,
|
@@ -335,18 +476,22 @@ describe("New HtmlReporter", function() {
|
|
335
476
|
});
|
336
477
|
reporter.initialize();
|
337
478
|
|
338
|
-
reporter.jasmineStarted({});
|
479
|
+
reporter.jasmineStarted({ totalSpecsDefined: 2 });
|
339
480
|
reporter.specDone({
|
340
481
|
id: 123,
|
341
482
|
description: "with a spec",
|
342
483
|
fullName: "A Suite with a spec",
|
343
|
-
status: "passed"
|
484
|
+
status: "passed",
|
485
|
+
passedExpectations: [{passed: true}],
|
486
|
+
failedExpectations: []
|
344
487
|
});
|
345
488
|
reporter.specDone({
|
346
489
|
id: 124,
|
347
490
|
description: "with another spec",
|
348
491
|
fullName: "A Suite inner suite with another spec",
|
349
|
-
status: "passed"
|
492
|
+
status: "passed",
|
493
|
+
passedExpectations: [{passed: true}],
|
494
|
+
failedExpectations: []
|
350
495
|
});
|
351
496
|
reporter.jasmineDone({});
|
352
497
|
});
|
@@ -377,21 +522,23 @@ describe("New HtmlReporter", function() {
|
|
377
522
|
beforeEach(function() {
|
378
523
|
env = new j$.Env();
|
379
524
|
container = document.createElement("div");
|
380
|
-
getContainer = function() { return container; }
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
525
|
+
var getContainer = function() { return container; };
|
526
|
+
reporter = new j$.HtmlReporter({
|
527
|
+
env: env,
|
528
|
+
getContainer: getContainer,
|
529
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
530
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
531
|
+
});
|
387
532
|
reporter.initialize();
|
388
533
|
|
389
|
-
reporter.jasmineStarted({});
|
534
|
+
reporter.jasmineStarted({ totalSpecsDefined: 1 });
|
390
535
|
reporter.specDone({
|
391
536
|
id: 123,
|
392
537
|
description: "with a spec",
|
393
538
|
fullName: "A Suite with a spec",
|
394
|
-
status: "pending"
|
539
|
+
status: "pending",
|
540
|
+
passedExpectations: [],
|
541
|
+
failedExpectations: []
|
395
542
|
});
|
396
543
|
reporter.jasmineDone({});
|
397
544
|
});
|
@@ -414,19 +561,19 @@ describe("New HtmlReporter", function() {
|
|
414
561
|
|
415
562
|
beforeEach(function() {
|
416
563
|
env = new j$.Env();
|
417
|
-
container = document.createElement("div")
|
418
|
-
getContainer = function() { return container; }
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
564
|
+
container = document.createElement("div");
|
565
|
+
var getContainer = function() { return container; }
|
566
|
+
reporter = new j$.HtmlReporter({
|
567
|
+
env: env,
|
568
|
+
getContainer: getContainer,
|
569
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
570
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
571
|
+
});
|
425
572
|
reporter.initialize();
|
426
573
|
|
427
|
-
reporter.jasmineStarted({});
|
574
|
+
reporter.jasmineStarted({ totalSpecsDefined: 1 });
|
428
575
|
|
429
|
-
var passingResult = {id: 123, status: "passed"};
|
576
|
+
var passingResult = {id: 123, status: "passed", passedExpectations: [{passed: true}], failedExpectations: []};
|
430
577
|
reporter.specStarted(passingResult);
|
431
578
|
reporter.specDone(passingResult);
|
432
579
|
|
@@ -435,6 +582,7 @@ describe("New HtmlReporter", function() {
|
|
435
582
|
status: "failed",
|
436
583
|
description: "a failing spec",
|
437
584
|
fullName: "a suite with a failing spec",
|
585
|
+
passedExpectations: [],
|
438
586
|
failedExpectations: [
|
439
587
|
{
|
440
588
|
message: "a failure message",
|
@@ -488,7 +636,7 @@ describe("New HtmlReporter", function() {
|
|
488
636
|
});
|
489
637
|
|
490
638
|
it("sets the reporter to 'Failures List' mode", function() {
|
491
|
-
var reporterNode = container.querySelector(".
|
639
|
+
var reporterNode = container.querySelector(".jasmine_html-reporter");
|
492
640
|
expect(reporterNode.getAttribute("class")).toMatch("failure-list");
|
493
641
|
});
|
494
642
|
});
|
@@ -3,7 +3,7 @@ describe("j$.pp (HTML Dependent)", function () {
|
|
3
3
|
var sampleNode = document.createElement('div');
|
4
4
|
sampleNode.innerHTML = 'foo<b>bar</b>';
|
5
5
|
expect(j$.pp(sampleNode)).toEqual("HTMLNode");
|
6
|
-
expect(j$.pp({foo: sampleNode})).toEqual("{ foo
|
6
|
+
expect(j$.pp({foo: sampleNode})).toEqual("{ foo: HTMLNode }");
|
7
7
|
});
|
8
8
|
|
9
9
|
it("should print Firefox's wrapped native objects correctly", function() {
|
@@ -47,7 +47,15 @@ var jasmineInterface = {
|
|
47
47
|
|
48
48
|
jsApiReporter: new jasmine.JsApiReporter({
|
49
49
|
timer: new jasmine.Timer()
|
50
|
-
})
|
50
|
+
}),
|
51
|
+
|
52
|
+
beforeAll: function(beforeAllFunction) {
|
53
|
+
return env.beforeAll(beforeAllFunction);
|
54
|
+
},
|
55
|
+
|
56
|
+
afterAll: function(afterAllFunction) {
|
57
|
+
return env.afterAll(afterAllFunction);
|
58
|
+
}
|
51
59
|
};
|
52
60
|
|
53
61
|
extend(global, jasmineInterface);
|
@@ -0,0 +1,104 @@
|
|
1
|
+
describe('npm package', function() {
|
2
|
+
var path = require('path'),
|
3
|
+
fs = require('fs');
|
4
|
+
|
5
|
+
beforeAll(function() {
|
6
|
+
var shell = require('shelljs'),
|
7
|
+
pack = shell.exec('npm pack', { silent: true });
|
8
|
+
|
9
|
+
this.tarball = pack.output.split('\n')[0];
|
10
|
+
this.tmpDir = '/tmp/jasmine-core';
|
11
|
+
|
12
|
+
fs.mkdirSync(this.tmpDir);
|
13
|
+
|
14
|
+
var untar = shell.exec('tar -xzf ' + this.tarball + ' -C ' + this.tmpDir, { silent: true });
|
15
|
+
expect(untar.code).toBe(0);
|
16
|
+
|
17
|
+
this.packagedCore = require(path.join(this.tmpDir, 'package/lib/jasmine-core.js'));
|
18
|
+
});
|
19
|
+
|
20
|
+
beforeEach(function() {
|
21
|
+
jasmine.addMatchers({
|
22
|
+
toExistInPath: function(util, customEquality) {
|
23
|
+
return {
|
24
|
+
compare: function(actual, expected) {
|
25
|
+
var fullPath = path.resolve(expected, actual);
|
26
|
+
return {
|
27
|
+
pass: fs.existsSync(fullPath)
|
28
|
+
};
|
29
|
+
}
|
30
|
+
};
|
31
|
+
}
|
32
|
+
});
|
33
|
+
});
|
34
|
+
|
35
|
+
afterAll(function() {
|
36
|
+
var cleanup = function (parent, fileOrFolder) {
|
37
|
+
var fullPath = path.join(parent, fileOrFolder);
|
38
|
+
if (fs.statSync(fullPath).isFile()) {
|
39
|
+
fs.unlinkSync(fullPath);
|
40
|
+
} else {
|
41
|
+
fs.readdirSync(fullPath).forEach(cleanup.bind(null, fullPath));
|
42
|
+
fs.rmdirSync(fullPath);
|
43
|
+
}
|
44
|
+
};
|
45
|
+
|
46
|
+
fs.unlink(this.tarball);
|
47
|
+
fs.readdirSync(this.tmpDir).forEach(cleanup.bind(null, this.tmpDir));
|
48
|
+
fs.rmdirSync(this.tmpDir);
|
49
|
+
});
|
50
|
+
|
51
|
+
it('has a root path', function() {
|
52
|
+
expect(this.packagedCore.files.path).toEqual(fs.realpathSync(path.resolve(this.tmpDir, 'package/lib/jasmine-core')));
|
53
|
+
});
|
54
|
+
|
55
|
+
it('has a bootDir', function() {
|
56
|
+
expect(this.packagedCore.files.bootDir).toEqual(fs.realpathSync(path.resolve(this.tmpDir, 'package/lib/jasmine-core')));
|
57
|
+
});
|
58
|
+
|
59
|
+
it('has jsFiles', function() {
|
60
|
+
expect(this.packagedCore.files.jsFiles).toEqual([
|
61
|
+
'jasmine.js',
|
62
|
+
'jasmine-html.js',
|
63
|
+
'json2.js'
|
64
|
+
]);
|
65
|
+
|
66
|
+
var packagedCore = this.packagedCore;
|
67
|
+
this.packagedCore.files.jsFiles.forEach(function(fileName) {
|
68
|
+
expect(fileName).toExistInPath(packagedCore.files.path);
|
69
|
+
});
|
70
|
+
});
|
71
|
+
|
72
|
+
it('has cssFiles', function() {
|
73
|
+
expect(this.packagedCore.files.cssFiles).toEqual(['jasmine.css']);
|
74
|
+
|
75
|
+
var packagedCore = this.packagedCore;
|
76
|
+
this.packagedCore.files.cssFiles.forEach(function(fileName) {
|
77
|
+
expect(fileName).toExistInPath(packagedCore.files.path);
|
78
|
+
});
|
79
|
+
});
|
80
|
+
|
81
|
+
it('has bootFiles', function() {
|
82
|
+
expect(this.packagedCore.files.bootFiles).toEqual(['boot.js']);
|
83
|
+
expect(this.packagedCore.files.nodeBootFiles).toEqual(['node_boot.js']);
|
84
|
+
|
85
|
+
var packagedCore = this.packagedCore;
|
86
|
+
this.packagedCore.files.bootFiles.forEach(function(fileName) {
|
87
|
+
expect(fileName).toExistInPath(packagedCore.files.bootDir);
|
88
|
+
});
|
89
|
+
|
90
|
+
var packagedCore = this.packagedCore;
|
91
|
+
this.packagedCore.files.nodeBootFiles.forEach(function(fileName) {
|
92
|
+
expect(fileName).toExistInPath(packagedCore.files.bootDir);
|
93
|
+
});
|
94
|
+
});
|
95
|
+
|
96
|
+
it('has an imagesDir', function() {
|
97
|
+
expect(this.packagedCore.files.imagesDir).toEqual(fs.realpathSync(path.resolve(this.tmpDir, 'package/images')));
|
98
|
+
var images = fs.readdirSync(path.resolve(this.tmpDir, 'package/images'));
|
99
|
+
|
100
|
+
expect(images).toContain('jasmine-horizontal.png');
|
101
|
+
expect(images).toContain('jasmine-horizontal.svg');
|
102
|
+
expect(images).toContain('jasmine_favicon.png');
|
103
|
+
});
|
104
|
+
});
|
@@ -0,0 +1,36 @@
|
|
1
|
+
describe('Printing a big object', function(){
|
2
|
+
var bigObject;
|
3
|
+
function rand(upper) {
|
4
|
+
return Math.round(upper * Math.random());
|
5
|
+
}
|
6
|
+
|
7
|
+
function generateObject(level) {
|
8
|
+
var object = {};
|
9
|
+
|
10
|
+
for (var i = 0; i < 50; i++) {
|
11
|
+
var decide = rand(2);
|
12
|
+
switch (decide) {
|
13
|
+
case 0:
|
14
|
+
object["cycle" + i] = object;
|
15
|
+
break;
|
16
|
+
case 1:
|
17
|
+
object["number" + i] = rand(100);
|
18
|
+
break;
|
19
|
+
case 2:
|
20
|
+
if (level < 3) {
|
21
|
+
object["nesting" + i] = generateObject(level + 1);
|
22
|
+
}
|
23
|
+
break;
|
24
|
+
}
|
25
|
+
|
26
|
+
}
|
27
|
+
|
28
|
+
return object;
|
29
|
+
}
|
30
|
+
|
31
|
+
it('takes a resonable amount of time', function(){
|
32
|
+
bigObject = generateObject(0);
|
33
|
+
expect(j$.pp(bigObject)).toMatch(/cycle/);
|
34
|
+
});
|
35
|
+
});
|
36
|
+
|
data/lib/jasmine-core/version.rb
CHANGED
data/lib/jasmine-core.js
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module.exports = require("./jasmine-core/jasmine.js");
|
2
|
+
module.exports.boot = require('./jasmine-core/node_boot.js');
|
3
|
+
|
4
|
+
var path = require('path'),
|
5
|
+
fs = require('fs');
|
6
|
+
|
7
|
+
var rootPath = path.join(__dirname, "jasmine-core"),
|
8
|
+
bootFiles = ['boot.js'],
|
9
|
+
nodeBootFiles = ['node_boot.js'],
|
10
|
+
cssFiles = [],
|
11
|
+
jsFiles = [],
|
12
|
+
jsFilesToSkip = ['jasmine.js'].concat(bootFiles, nodeBootFiles);
|
13
|
+
|
14
|
+
fs.readdirSync(rootPath).forEach(function(file) {
|
15
|
+
if(fs.statSync(path.join(rootPath, file)).isFile()) {
|
16
|
+
switch(path.extname(file)) {
|
17
|
+
case '.css':
|
18
|
+
cssFiles.push(file);
|
19
|
+
break;
|
20
|
+
case '.js':
|
21
|
+
if (jsFilesToSkip.indexOf(file) < 0) {
|
22
|
+
jsFiles.push(file);
|
23
|
+
}
|
24
|
+
break;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
});
|
28
|
+
|
29
|
+
module.exports.files = {
|
30
|
+
path: rootPath,
|
31
|
+
bootDir: rootPath,
|
32
|
+
bootFiles: bootFiles,
|
33
|
+
nodeBootFiles: nodeBootFiles,
|
34
|
+
cssFiles: cssFiles,
|
35
|
+
jsFiles: ['jasmine.js'].concat(jsFiles),
|
36
|
+
imagesDir: path.join(__dirname, '../images')
|
37
|
+
};
|
data/lib/jasmine-core.rb
CHANGED
@@ -6,7 +6,7 @@ module Jasmine
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def js_files
|
9
|
-
(["jasmine.js"] + Dir.glob(File.join(path, "*.js"))).map { |f| File.basename(f) }.uniq - boot_files
|
9
|
+
(["jasmine.js"] + Dir.glob(File.join(path, "*.js"))).map { |f| File.basename(f) }.uniq - boot_files - node_boot_files
|
10
10
|
end
|
11
11
|
|
12
12
|
SPEC_TYPES = ["core", "html", "node"]
|
@@ -27,8 +27,12 @@ module Jasmine
|
|
27
27
|
["boot.js"]
|
28
28
|
end
|
29
29
|
|
30
|
+
def node_boot_files
|
31
|
+
["node_boot.js"]
|
32
|
+
end
|
33
|
+
|
30
34
|
def boot_dir
|
31
|
-
|
35
|
+
path
|
32
36
|
end
|
33
37
|
|
34
38
|
def spec_files(type)
|