File tree Expand file tree Collapse file tree 2 files changed +3
-4
lines changed
Expand file tree Collapse file tree 2 files changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ describe('AST Unit Tests', () => {
7575 expect ( getHooksNames ( elementType ) ) . toEqual ( [ 'testCount' , 'setTestCount' ] ) ;
7676 } ) ;
7777
78- it ( 'Should output the right number of properties when taking in multiple function definitions ' , ( ) => {
78+ it ( 'Should output the right number of properties when given multiple hooks ' , ( ) => {
7979 const elementType = `function SingleUseFakeComponent() {
8080 const [testCount, setTestCount] = useState(0);
8181 const [biscuitCount, setBiscuitCount] = useState(0);
Original file line number Diff line number Diff line change @@ -91,9 +91,8 @@ export const getHooksNames = (elementType: string): Array<string> => {
9191 // * Works for useState hooks
9292 if ( hook . id . type === 'ArrayPattern' ) {
9393 hook . id . elements . forEach ( ( hook ) => {
94+ statements . push ( `_useWildcard${ tsCount } ` ) ;
9495 statements . push ( hook . name ) ;
95- // * Unshift a wildcard name to achieve similar functionality as before
96- statements . unshift ( `_useWildcard${ tsCount } ` ) ;
9796 tsCount += 1 ;
9897 } ) ;
9998 } else {
@@ -111,7 +110,7 @@ export const getHooksNames = (elementType: string): Array<string> => {
111110 }
112111 } ) ;
113112 statements . forEach ( ( el , i ) => {
114- if ( el . match ( / _ u s e / ) ) hooksNames [ el ] = statements [ i + 2 ] ;
113+ if ( el . match ( / _ u s e / ) ) hooksNames [ el ] = statements [ i + 1 ] ;
115114 } ) ;
116115 } ) ;
117116 }
You can’t perform that action at this time.
0 commit comments