@@ -19,45 +19,40 @@ describe('objects', () => {
1919 expect ( inspect ( { foo : 1 , [ Symbol ( 'foo' ) ] : 1 } ) ) . to . equal ( '{ foo: 1, [Symbol(foo)]: 1 }' )
2020 } )
2121
22- it ( 'does not use custom inspect functions if `customInspect` is turned off ' , ( ) => {
22+ it ( 'does not treat inspect members as inspect functions ' , ( ) => {
2323 const obj = {
2424 inspect : ( ) => 1 ,
2525 }
26- expect ( inspect ( obj , { customInspect : false } ) ) . to . equal ( '{ inspect: [Function inspect] }' )
27- } )
28-
29- it ( 'uses custom inspect function is `customInspect` is turned on' , ( ) => {
30- const obj = {
31- inspect : ( ) => 1 ,
32- }
33- expect ( inspect ( obj , { customInspect : true } ) ) . to . equal ( '1' )
26+ expect ( inspect ( obj ) ) . to . equal ( '{ inspect: [Function inspect] }' )
3427 } )
3528
3629 it ( 'does not use custom inspect functions if `customInspect` is turned off' , ( ) => {
3730 const obj = {
38- inspect : ( ) => 1 ,
31+ [ Symbol . for ( 'nodejs.util. inspect.custom' ) ] : ( ) => 1 ,
3932 }
40- expect ( inspect ( obj , { customInspect : false } ) ) . to . equal ( '{ inspect: [Function inspect] }' )
33+ expect ( inspect ( obj , { customInspect : false } ) ) . to . equal (
34+ '{ [Symbol(nodejs.util.inspect.custom)]: [Function [nodejs.util.inspect.custom]] }'
35+ )
4136 } )
4237
4338 it ( 'uses custom inspect function if `customInspect` is turned on' , ( ) => {
4439 const obj = {
45- inspect : ( ) => 'abc' ,
40+ [ Symbol . for ( 'nodejs.util. inspect.custom' ) ] : ( ) => 1 ,
4641 }
47- expect ( inspect ( obj , { customInspect : true } ) ) . to . equal ( 'abc ' )
42+ expect ( inspect ( obj , { customInspect : true } ) ) . to . equal ( '1 ' )
4843 } )
4944
5045 it ( 'inspects custom inspect function result' , ( ) => {
5146 const obj = {
52- inspect : ( ) => [ 'foobarbazbing' ] ,
47+ [ Symbol . for ( 'nodejs.util. inspect.custom' ) ] : ( ) => [ 'foobarbazbing' ] ,
5348 }
5449 expect ( inspect ( obj , { customInspect : true , truncate : 15 } ) ) . to . equal ( "[ 'foobarba…' ]" )
5550 } )
5651
5752 it ( 'uses a custom deeply nested inspect function if `customInspect` is turned on' , ( ) => {
5853 const obj = {
5954 sub : {
60- inspect : ( depth , options ) => options . stylize ( 'Object content' , 'string' ) ,
55+ [ Symbol . for ( 'nodejs.util. inspect.custom' ) ] : ( depth , options ) => options . stylize ( 'Object content' , 'string' ) ,
6156 } ,
6257 }
6358 expect ( inspect ( obj , { customInspect : true } ) ) . to . equal ( '{ sub: Object content }' )
@@ -66,7 +61,7 @@ describe('objects', () => {
6661 it ( 'inspect with custom object-returning inspect' , ( ) => {
6762 const obj = {
6863 sub : {
69- inspect : ( ) => ( { foo : 'bar' } ) ,
64+ [ Symbol . for ( 'nodejs.util. inspect.custom' ) ] : ( ) => ( { foo : 'bar' } ) ,
7065 } ,
7166 }
7267
0 commit comments