@@ -168,12 +168,14 @@ describe("console.js", function () {
168
168
169
169
it ( "does not add stack trace when stacktrace.js is not installed" , function ( ) {
170
170
// 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" ;
173
175
window . printStackTrace = null ;
174
176
175
177
// When
176
- console . addStackTrace ( data ) ;
178
+ console . addStackTrace ( data , error ) ;
177
179
178
180
// Then
179
181
expect ( data . stackTrace ) . toBeUndefined ( ) ;
@@ -204,8 +206,9 @@ describe("console.js", function () {
204
206
205
207
it ( "adds the error stack trace when stacktrace.js is installed" , function ( ) {
206
208
// Given
207
- var error = new Error ( "Oops!" ) ,
209
+ var error = Error ( "Oops!" ) ,
208
210
data = { level : "info" , message : "message" } ;
211
+ error . stack = "line1\nline2" ;
209
212
spyOn ( window , "printStackTrace" ) . and . callThrough ( ) ;
210
213
211
214
// When
@@ -222,7 +225,7 @@ describe("console.js", function () {
222
225
spyOn ( window , "printStackTrace" ) . and . returnValue ( [ "Oops1" , "Oops2" ] ) ;
223
226
224
227
// When
225
- console . addStackTrace ( data , new Error ( "Oops!" ) ) ;
228
+ console . addStackTrace ( data , Error ( "Oops!" ) ) ;
226
229
227
230
// Then
228
231
expect ( data . stackTrace ) . toBe ( "Oops1\nOops2" ) ;
@@ -313,7 +316,7 @@ describe("console.js", function () {
313
316
314
317
it ( "call and return the result of the original function" , function ( ) {
315
318
// Given
316
- var error = new Error ( "Oops" ) ;
319
+ var error = Error ( "Oops" ) ;
317
320
spyOn ( console , "warn" ) . and . returnValue ( "warn" ) ;
318
321
console . readConfig ( config )
319
322
. proxyConsoleFunctions ( ) ;
@@ -341,7 +344,7 @@ describe("console.js", function () {
341
344
342
345
it ( "adds a stack trace when an error is given in the arguments" , function ( ) {
343
346
// Given
344
- var error = new Error ( "Oops!" ) ;
347
+ var error = Error ( "Oops!" ) ;
345
348
console . readConfig ( config )
346
349
. proxyConsoleFunctions ( ) ;
347
350
spyOn ( console , "send" ) . and . stub ( ) ;
@@ -557,8 +560,11 @@ describe("console.js", function () {
557
560
config . levelEnabledOnServer = "warn" ;
558
561
559
562
// When
560
- console . readConfig ( config )
563
+ var returns = console . readConfig ( config )
561
564
. send ( { level : "error" , message : "messageError" } ) ;
565
+
566
+ // Then
567
+ expect ( returns ) . toBe ( console ) ;
562
568
} ) ;
563
569
} ) ;
564
570
0 commit comments