@@ -586,29 +586,24 @@ export type JestFunctionCallExpression<
586
586
| JestFunctionCallExpressionWithMemberExpressionCallee < FunctionName >
587
587
| JestFunctionCallExpressionWithIdentifierCallee < FunctionName > ;
588
588
589
+ const joinNames = ( a : string | null , b : string | null ) : string | null =>
590
+ a && b ? `${ a } .${ b } ` : null ;
591
+
589
592
export function getNodeName (
590
593
node :
591
594
| JestFunctionMemberExpression < JestFunctionName >
592
595
| JestFunctionIdentifier < JestFunctionName > ,
593
596
) : string ;
594
597
export function getNodeName ( node : TSESTree . Node ) : string | null ;
595
598
export function getNodeName ( node : TSESTree . Node ) : string | null {
596
- function joinNames ( a ?: string | null , b ?: string | null ) : string | null {
597
- return a && b ? ` ${ a } . ${ b } ` : null ;
599
+ if ( isSupportedAccessor ( node ) ) {
600
+ return getAccessorValue ( node ) ;
598
601
}
599
602
600
603
switch ( node . type ) {
601
- case AST_NODE_TYPES . Identifier :
602
- return node . name ;
603
- case AST_NODE_TYPES . Literal :
604
- return `${ node . value } ` ;
605
- case AST_NODE_TYPES . TemplateLiteral :
606
- if ( node . expressions . length === 0 ) return node . quasis [ 0 ] . value . cooked ;
607
- break ;
608
604
case AST_NODE_TYPES . MemberExpression :
609
605
return joinNames ( getNodeName ( node . object ) , getNodeName ( node . property ) ) ;
610
606
case AST_NODE_TYPES . NewExpression :
611
- return getNodeName ( node . callee ) ;
612
607
case AST_NODE_TYPES . CallExpression :
613
608
return getNodeName ( node . callee ) ;
614
609
}
0 commit comments