@@ -3,31 +3,58 @@ const { search } = require('../src/general');
33
44describe . each ( [
55 [ 'queryDb' , 'js' , 'js' , 1 ] ,
6- [ 'makeQuery' , 'js' , 'js' , 3 ] ,
7- [ 'parseQuery' , 'js' , 'js' , 5 ] ,
8- [ 'parseQuery' , 'js' , 'js_2_files' , 5 ] ,
9- [ 'parseQuery' , 'js' , 'js_directory' , 5 ] ,
10- [ 'objectWithFunctionShorthand' , 'js' , 'js' , 9 ] ,
11- [ 'shorthandFunction' , 'js' , 'js' , 10 ] ,
12- [ 'shorthandFunction' , undefined , 'js' , 10 ] , // auto-detect type
13- [ 'shorthandFunction' , undefined , 'js_2_files' , 10 ] , // auto_detect type
14- [ 'shorthandFunction' , undefined , 'js_directory' , 10 ] , // auto_detect type
15- [ 'shorthandFunction' , undefined , 'js_parent_directory' , 10 ] , // auto_detect type
6+ [ 'queryDbTS' , 'js' , 'ts' , 1 ] ,
7+ [ 'makeQuery' , 'js' , 'js' , 4 ] ,
8+ [ 'makeQueryTS' , 'js' , 'ts' , 4 ] ,
9+ [ 'parseQuery' , 'js' , 'js' , 7 ] ,
10+ [ 'parseQuery' , 'js' , 'js_2_files' , 7 ] ,
11+ [ 'parseQuery' , 'js' , 'js_directory' , 7 ] ,
12+ [ 'parseQueryTS' , 'js' , 'ts' , 7 ] ,
13+ [ 'objectWithFunctionShorthand' , 'js' , 'js' , 15 ] ,
14+ [ 'objectWithFunctionShorthandTS' , 'js' , 'ts' , 15 ] ,
15+ [ 'shorthandFunction' , 'js' , 'js' , 16 ] ,
16+ [ 'shorthandFunctionTS' , 'js' , 'ts' , 16 ] ,
17+ [ 'shorthandFunction' , undefined , 'js' , 16 ] , // auto-detect type
18+ [ 'shorthandFunctionTS' , undefined , 'ts' , 16 ] , // auto-detect type
19+ [ 'shorthandFunction' , undefined , 'js_2_files' , 16 ] , // auto_detect type
20+ [ 'shorthandFunction' , undefined , 'js_directory' , 16 ] , // auto_detect type
21+ [ 'shorthandFunction' , undefined , 'js_parent_directory' , 16 ] , // auto_detect type
22+ [ 'longhandFunction' , undefined , 'js_parent_directory' , 25 ] , // auto_detect type
23+ [ 'longhandFunctionTS' , undefined , 'ts' , 25 ] , // auto_detect type
24+ [ 'longhandArrowFunction' , undefined , 'js_parent_directory' , 34 ] , // auto_detect type
25+ [ 'longhandArrowFunctionTS' , undefined , 'ts' , 34 ] , // auto_detect type
26+ [ 'longhandProperty' , undefined , 'js_parent_directory' , 43 ] , // auto_detect type
27+ [ 'longhandPropertyTS' , undefined , 'ts' , 43 ] , // auto_detect type
28+ [ 'AnInterface' , undefined , 'ts' , 59 ] , // auto_detect type
29+ [ 'AType' , undefined , 'ts' , 63 ] , // auto_detect type
30+ [ 'TypeDefObject' , undefined , 'ts' , 66 ] , // auto_detect type
31+ [ 'TypeDefSimple' , undefined , 'ts' , 72 ] , // auto_detect type
1632 [ 'queryDb' , 'php' , 'php' , 2 ] ,
1733 [ '$makeQuery' , 'php' , 'php' , 4 ] ,
1834 [ 'parseQuery' , 'php' , 'php' , 6 ] ,
1935 [ 'Foo' , 'php' , 'php' , 11 ] ,
2036 [ 'Bar' , 'php' , 'php' , 14 ] ,
2137 [ 'Zoom' , 'php' , 'php' , 17 ] ,
2238 [ 'Zoom' , undefined , 'php' , 17 ] , // auto-detect type
23- ] ) ( "search('%s', {type: '%s', path: '%s'})" , ( symbol , type , fixtureType , expectedLine ) => {
39+ ] ) ( "search('%s', {type: '%s', path: '%s'})" ,
40+
41+ /**
42+ * @param {string } symbol
43+ * @param {import('../src/general').FileType } type
44+ * @param {string } fixtureType
45+ * @param {number } expectedLine
46+ */
47+ ( symbol , type , fixtureType , expectedLine ) => {
2448 test ( `finds line '${ expectedLine } '` , async ( ) => {
2549 const path = getFixtureForType ( fixtureType ) ;
50+
51+ /** @type {import('../src/general').SearchConfig } */
2652 const config = {
2753 type,
2854 searchTool : 'ripgrep' ,
2955 path,
3056 } ;
57+
3158 const results = await search ( symbol , config ) ;
3259 expect ( results . length ) . toEqual ( 1 ) ;
3360 const result = results [ 0 ] ;
@@ -43,6 +70,8 @@ describe.each([
4370 */
4471function getFixtureForType ( type ) {
4572 switch ( type ) {
73+ case 'ts' :
74+ return './tests/fixtures/js/misc.ts' ;
4675 case 'js' :
4776 return './tests/fixtures/js/db.js' ;
4877 case 'js_2_files' :
@@ -64,6 +93,8 @@ function getFixtureForType(type) {
6493 */
6594function getExpectedResultPath ( type ) {
6695 switch ( type ) {
96+ case 'ts' :
97+ return './tests/fixtures/js/misc.ts' ;
6798 case 'js' :
6899 case 'js_2_files' :
69100 case 'js_directory' :
0 commit comments