Skip to content
This repository was archived by the owner on Sep 14, 2023. It is now read-only.

Commit 92c873a

Browse files
author
Mickaël Tricot
committed
Upgrade and fix tests for stacktrace.js 0.6.4
1 parent 21c5391 commit 92c873a

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = function (grunt) {
1515
outfile: ".grunt/SpecRunner.html",
1616
specs: tests,
1717
vendor: [
18-
"http://cdnjs.cloudflare.com/ajax/libs/stacktrace.js/0.6.2/stacktrace.js",
18+
"http://cdnjs.cloudflare.com/ajax/libs/stacktrace.js/0.6.4/stacktrace.js",
1919
"http://localhost:35729/livereload.js"
2020
]
2121
},

tests/consoleSpec.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,14 @@ describe("console.js", function () {
168168

169169
it("does not add stack trace when stacktrace.js is not installed", function () {
170170
// Given
171-
var printStackTrace = window.printStackTrace,
172-
data = {level: "info", message: "message", stackTrace: ""};
171+
var error = Error("Oops!"),
172+
data = {level: "info", message: "message", stackTrace: ""},
173+
printStackTrace = window.printStackTrace;
174+
error.stack = "line1\nline2";
173175
window.printStackTrace = null;
174176

175177
// When
176-
console.addStackTrace(data);
178+
console.addStackTrace(data, error);
177179

178180
// Then
179181
expect(data.stackTrace).toBeUndefined();
@@ -204,8 +206,9 @@ describe("console.js", function () {
204206

205207
it("adds the error stack trace when stacktrace.js is installed", function () {
206208
// Given
207-
var error = new Error("Oops!"),
209+
var error = Error("Oops!"),
208210
data = {level: "info", message: "message"};
211+
error.stack = "line1\nline2";
209212
spyOn(window, "printStackTrace").and.callThrough();
210213

211214
// When
@@ -222,7 +225,7 @@ describe("console.js", function () {
222225
spyOn(window, "printStackTrace").and.returnValue(["Oops1", "Oops2"]);
223226

224227
// When
225-
console.addStackTrace(data, new Error("Oops!"));
228+
console.addStackTrace(data, Error("Oops!"));
226229

227230
// Then
228231
expect(data.stackTrace).toBe("Oops1\nOops2");
@@ -313,7 +316,7 @@ describe("console.js", function () {
313316

314317
it("call and return the result of the original function", function () {
315318
// Given
316-
var error = new Error("Oops");
319+
var error = Error("Oops");
317320
spyOn(console, "warn").and.returnValue("warn");
318321
console.readConfig(config)
319322
.proxyConsoleFunctions();
@@ -341,7 +344,7 @@ describe("console.js", function () {
341344

342345
it("adds a stack trace when an error is given in the arguments", function () {
343346
// Given
344-
var error = new Error("Oops!");
347+
var error = Error("Oops!");
345348
console.readConfig(config)
346349
.proxyConsoleFunctions();
347350
spyOn(console, "send").and.stub();
@@ -557,8 +560,11 @@ describe("console.js", function () {
557560
config.levelEnabledOnServer = "warn";
558561

559562
// When
560-
console.readConfig(config)
563+
var returns = console.readConfig(config)
561564
.send({level: "error", message: "messageError"});
565+
566+
// Then
567+
expect(returns).toBe(console);
562568
});
563569
});
564570

0 commit comments

Comments
 (0)