@@ -372,4 +372,71 @@ describe('getFullName', () => {
372372 ) ;
373373 assert . strictEqual ( result , 'fallbackValue' ) ;
374374 } ) ;
375+
376+ it ( 'skips occurrences of the name within the receiver' , ( ) => {
377+ const result = getFullName ( {
378+ name : 'channel' ,
379+ text : '`diagnostics_channel.channel(name)`' ,
380+ } ) ;
381+ assert . strictEqual ( result , 'diagnostics_channel.channel' ) ;
382+ } ) ;
383+
384+ it ( 'skips occurrences of the name that are a prefix of the receiver' , ( ) => {
385+ const result = getFullName ( {
386+ name : 'read' ,
387+ text : '`readable.read([size])`' ,
388+ } ) ;
389+ assert . strictEqual ( result , 'readable.read' ) ;
390+ } ) ;
391+
392+ it ( 'ignores parameters repeating the name' , ( ) => {
393+ const result = getFullName ( {
394+ name : 'percentile' ,
395+ text : '`histogram.percentile(percentile)`' ,
396+ } ) ;
397+ assert . strictEqual ( result , 'histogram.percentile' ) ;
398+ } ) ;
399+
400+ it ( 'handles symbol-keyed methods' , ( ) => {
401+ const result = getFullName ( {
402+ name : "[Symbol.for('nodejs.rejection')]" ,
403+ text : "`emitter[Symbol.for('nodejs.rejection')](err, eventName[, ...args])`" ,
404+ } ) ;
405+ assert . strictEqual ( result , "emitter[Symbol.for('nodejs.rejection')]" ) ;
406+ } ) ;
407+
408+ it ( 'keeps quoted names intact' , ( ) => {
409+ const result = getFullName ( {
410+ name : 'console.log' ,
411+ text : "Event: `'console.log'`" ,
412+ } ) ;
413+ assert . strictEqual ( result , 'console.log' ) ;
414+ } ) ;
415+
416+ it ( 'does not strip "new" from within a name' , ( ) => {
417+ const result = getFullName ( {
418+ name : 'newListener' ,
419+ text : "Event: `'newListener'`" ,
420+ } ) ;
421+ assert . strictEqual ( result , 'newListener' ) ;
422+ } ) ;
423+
424+ it ( 'does not strip "new" from within a dotted name' , ( ) => {
425+ const result = getFullName ( {
426+ name : 'onnewtoken' ,
427+ text : '`session.onnewtoken`' ,
428+ } ) ;
429+ assert . strictEqual ( result , 'session.onnewtoken' ) ;
430+ } ) ;
431+
432+ it ( 'returns fallback when no occurrence terminates the name' , ( ) => {
433+ const result = getFullName (
434+ {
435+ name : 'read' ,
436+ text : '`readable`' ,
437+ } ,
438+ 'fallback'
439+ ) ;
440+ assert . strictEqual ( result , 'fallback' ) ;
441+ } ) ;
375442} ) ;
0 commit comments