1- /* eslint no-console: 0 */
21describe ( 'Deprecator' , function ( ) {
32 describe ( '#deprecate' , function ( ) {
43 beforeEach ( function ( ) {
5- spyOn ( console , 'error ' ) ;
4+ spyOn ( privateUnderTest , 'consoleError ' ) ;
65 } ) ;
76
87 it ( 'logs the mesage without context when the runnable is the top suite' , function ( ) {
@@ -14,7 +13,9 @@ describe('Deprecator', function() {
1413 omitStackTrace : true
1514 } ) ;
1615
17- expect ( console . error ) . toHaveBeenCalledWith ( 'DEPRECATION: the message' ) ;
16+ expect ( privateUnderTest . consoleError ) . toHaveBeenCalledWith (
17+ 'DEPRECATION: the message'
18+ ) ;
1819 } ) ;
1920
2021 it ( 'logs the message in a descendant suite' , function ( ) {
@@ -32,7 +33,7 @@ describe('Deprecator', function() {
3233 omitStackTrace : true
3334 } ) ;
3435
35- expect ( console . error ) . toHaveBeenCalledWith (
36+ expect ( privateUnderTest . consoleError ) . toHaveBeenCalledWith (
3637 'DEPRECATION: the message (in suite: the suite)'
3738 ) ;
3839 } ) ;
@@ -51,7 +52,7 @@ describe('Deprecator', function() {
5152 omitStackTrace : true
5253 } ) ;
5354
54- expect ( console . error ) . toHaveBeenCalledWith (
55+ expect ( privateUnderTest . consoleError ) . toHaveBeenCalledWith (
5556 'DEPRECATION: the message (in spec: the spec)'
5657 ) ;
5758 } ) ;
@@ -78,10 +79,10 @@ describe('Deprecator', function() {
7879 } )
7980 ) ;
8081 expect ( runnable . addDeprecationWarning ) . not . toHaveBeenCalled ( ) ;
81- expect ( console . error ) . toHaveBeenCalledWith (
82+ expect ( privateUnderTest . consoleError ) . toHaveBeenCalledWith (
8283 jasmine . stringMatching ( / t h e m e s s a g e / )
8384 ) ;
84- expect ( console . error ) . not . toHaveBeenCalledWith (
85+ expect ( privateUnderTest . consoleError ) . not . toHaveBeenCalledWith (
8586 jasmine . stringMatching ( / a s p e c / )
8687 ) ;
8788 } ) ;
@@ -176,8 +177,8 @@ describe('Deprecator', function() {
176177 expect (
177178 runnable . addDeprecationWarning . calls . argsFor ( 0 ) [ 0 ] . message
178179 ) . toContain ( verboseDeprecationsNote ( ) ) ;
179- expect ( console . error ) . toHaveBeenCalledTimes ( 1 ) ;
180- expect ( console . error . calls . argsFor ( 0 ) [ 0 ] ) . toContain (
180+ expect ( privateUnderTest . consoleError ) . toHaveBeenCalledTimes ( 1 ) ;
181+ expect ( privateUnderTest . consoleError . calls . argsFor ( 0 ) [ 0 ] ) . toContain (
181182 verboseDeprecationsNote ( )
182183 ) ;
183184 } ) ;
@@ -196,8 +197,8 @@ describe('Deprecator', function() {
196197 expect (
197198 runnable . addDeprecationWarning . calls . argsFor ( 0 ) [ 0 ] . message
198199 ) . not . toContain ( verboseDeprecationsNote ( ) ) ;
199- expect ( console . error ) . toHaveBeenCalledTimes ( 1 ) ;
200- expect ( console . error . calls . argsFor ( 0 ) [ 0 ] ) . not . toContain (
200+ expect ( privateUnderTest . consoleError ) . toHaveBeenCalledTimes ( 1 ) ;
201+ expect ( privateUnderTest . consoleError . calls . argsFor ( 0 ) [ 0 ] ) . not . toContain (
201202 verboseDeprecationsNote ( )
202203 ) ;
203204 } ) ;
@@ -230,11 +231,13 @@ describe('Deprecator', function() {
230231 expect ( runnable . addDeprecationWarning . calls . argsFor ( 0 ) [ 0 ] . stack ) . toBe (
231232 originalStack
232233 ) ;
233- expect ( console . error ) . toHaveBeenCalledTimes ( 1 ) ;
234- expect ( console . error . calls . argsFor ( 0 ) [ 0 ] . message ) . toEqual (
235- 'the deprecation'
234+ expect ( privateUnderTest . consoleError ) . toHaveBeenCalledTimes ( 1 ) ;
235+ expect (
236+ privateUnderTest . consoleError . calls . argsFor ( 0 ) [ 0 ] . message
237+ ) . toEqual ( 'the deprecation' ) ;
238+ expect ( privateUnderTest . consoleError . calls . argsFor ( 0 ) [ 0 ] . stack ) . toEqual (
239+ originalStack
236240 ) ;
237- expect ( console . error . calls . argsFor ( 0 ) [ 0 ] . stack ) . toEqual ( originalStack ) ;
238241 } ) ;
239242
240243 it ( 'reports the deprecation every time, regardless of config.verboseDeprecations' , function ( ) {
@@ -255,7 +258,7 @@ describe('Deprecator', function() {
255258 deprecator . addDeprecationWarning ( runnable , deprecation ) ;
256259
257260 expect ( runnable . addDeprecationWarning ) . toHaveBeenCalledTimes ( 2 ) ;
258- expect ( console . error ) . toHaveBeenCalledTimes ( 2 ) ;
261+ expect ( privateUnderTest . consoleError ) . toHaveBeenCalledTimes ( 2 ) ;
259262 } ) ;
260263
261264 it ( 'omits the note about verboseDeprecations' , function ( ) {
@@ -278,8 +281,8 @@ describe('Deprecator', function() {
278281 expect (
279282 runnable . addDeprecationWarning . calls . argsFor ( 0 ) [ 0 ] . message
280283 ) . not . toContain ( verboseDeprecationsNote ( ) ) ;
281- expect ( console . error ) . toHaveBeenCalledTimes ( 1 ) ;
282- expect ( console . error . calls . argsFor ( 0 ) [ 0 ] ) . not . toContain (
284+ expect ( privateUnderTest . consoleError ) . toHaveBeenCalledTimes ( 1 ) ;
285+ expect ( privateUnderTest . consoleError . calls . argsFor ( 0 ) [ 0 ] ) . not . toContain (
283286 verboseDeprecationsNote ( )
284287 ) ;
285288 } ) ;
@@ -305,9 +308,13 @@ describe('Deprecator', function() {
305308 message : jasmine . stringMatching ( / ^ t h e m e s s a g e / ) ,
306309 omitStackTrace : false
307310 } ) ;
308- expect ( console . error ) . toHaveBeenCalledTimes ( 1 ) ;
309- expect ( console . error . calls . argsFor ( 0 ) [ 0 ] ) . toContain ( 'the message' ) ;
310- expect ( console . error . calls . argsFor ( 0 ) [ 0 ] ) . toContain ( 'DeprecatorSpec.js' ) ;
311+ expect ( privateUnderTest . consoleError ) . toHaveBeenCalledTimes ( 1 ) ;
312+ expect ( privateUnderTest . consoleError . calls . argsFor ( 0 ) [ 0 ] ) . toContain (
313+ 'the message'
314+ ) ;
315+ expect ( privateUnderTest . consoleError . calls . argsFor ( 0 ) [ 0 ] ) . toContain (
316+ 'DeprecatorSpec.js'
317+ ) ;
311318 }
312319
313320 function testNoStackTrace ( options ) {
0 commit comments