@@ -34,6 +34,7 @@ import {
3434 impactAnalysisData ,
3535 moduleMapData ,
3636 queryNameData ,
37+ statsData ,
3738 whereData ,
3839} from '../../src/queries.js' ;
3940
@@ -470,3 +471,86 @@ describe('whereData', () => {
470471 expect ( data . results ) . toHaveLength ( 0 ) ;
471472 } ) ;
472473} ) ;
474+
475+ // ─── noTests filtering ───────────────────────────────────────────────
476+
477+ describe ( 'noTests filtering' , ( ) => {
478+ test ( 'queryNameData excludes test file nodes and callers' , ( ) => {
479+ const all = queryNameData ( 'authenticate' , dbPath ) ;
480+ const filtered = queryNameData ( 'authenticate' , dbPath , { noTests : true } ) ;
481+
482+ const allFn = all . results . find ( ( r ) => r . name === 'authenticate' && r . kind === 'function' ) ;
483+ const filteredFn = filtered . results . find (
484+ ( r ) => r . name === 'authenticate' && r . kind === 'function' ,
485+ ) ;
486+
487+ // testAuthenticate should be in callers without filter
488+ expect ( allFn . callers . map ( ( c ) => c . name ) ) . toContain ( 'testAuthenticate' ) ;
489+ // testAuthenticate should be excluded with noTests
490+ expect ( filteredFn . callers . map ( ( c ) => c . name ) ) . not . toContain ( 'testAuthenticate' ) ;
491+ } ) ;
492+
493+ test ( 'queryNameData excludes test file results' , ( ) => {
494+ const all = queryNameData ( 'testAuthenticate' , dbPath ) ;
495+ const filtered = queryNameData ( 'testAuthenticate' , dbPath , { noTests : true } ) ;
496+
497+ expect ( all . results ) . toHaveLength ( 1 ) ;
498+ expect ( filtered . results ) . toHaveLength ( 0 ) ;
499+ } ) ;
500+
501+ test ( 'statsData excludes test files from counts' , ( ) => {
502+ const all = statsData ( dbPath ) ;
503+ const filtered = statsData ( dbPath , { noTests : true } ) ;
504+
505+ // File count should be lower
506+ expect ( filtered . files . total ) . toBeLessThan ( all . files . total ) ;
507+ // Node count should be lower (test file + testAuthenticate removed)
508+ expect ( filtered . nodes . total ) . toBeLessThan ( all . nodes . total ) ;
509+ // Edge count should be lower (test import + test call edge removed)
510+ expect ( filtered . edges . total ) . toBeLessThan ( all . edges . total ) ;
511+ } ) ;
512+
513+ test ( 'statsData hotspots exclude test files' , ( ) => {
514+ const filtered = statsData ( dbPath , { noTests : true } ) ;
515+ for ( const h of filtered . hotspots ) {
516+ expect ( h . file ) . not . toMatch ( / \. t e s t \. / ) ;
517+ }
518+ } ) ;
519+
520+ test ( 'impactAnalysisData excludes test dependents' , ( ) => {
521+ const all = impactAnalysisData ( 'auth.js' , dbPath ) ;
522+ const filtered = impactAnalysisData ( 'auth.js' , dbPath , { noTests : true } ) ;
523+
524+ const allFiles = Object . values ( all . levels )
525+ . flat ( )
526+ . map ( ( f ) => f . file ) ;
527+ const filteredFiles = Object . values ( filtered . levels )
528+ . flat ( )
529+ . map ( ( f ) => f . file ) ;
530+
531+ expect ( allFiles ) . toContain ( 'auth.test.js' ) ;
532+ expect ( filteredFiles ) . not . toContain ( 'auth.test.js' ) ;
533+ } ) ;
534+
535+ test ( 'fileDepsData excludes test importers' , ( ) => {
536+ const all = fileDepsData ( 'auth.js' , dbPath ) ;
537+ const filtered = fileDepsData ( 'auth.js' , dbPath , { noTests : true } ) ;
538+
539+ const allImportedBy = all . results [ 0 ] . importedBy . map ( ( i ) => i . file ) ;
540+ const filteredImportedBy = filtered . results [ 0 ] . importedBy . map ( ( i ) => i . file ) ;
541+
542+ expect ( allImportedBy ) . toContain ( 'auth.test.js' ) ;
543+ expect ( filteredImportedBy ) . not . toContain ( 'auth.test.js' ) ;
544+ } ) ;
545+
546+ test ( 'moduleMapData excludes test files' , ( ) => {
547+ const all = moduleMapData ( dbPath , 20 ) ;
548+ const filtered = moduleMapData ( dbPath , 20 , { noTests : true } ) ;
549+
550+ const allFiles = all . topNodes . map ( ( n ) => n . file ) ;
551+ const filteredFiles = filtered . topNodes . map ( ( n ) => n . file ) ;
552+
553+ expect ( allFiles ) . toContain ( 'auth.test.js' ) ;
554+ expect ( filteredFiles ) . not . toContain ( 'auth.test.js' ) ;
555+ } ) ;
556+ } ) ;
0 commit comments