11import { expect , test } from 'vitest' ;
2- import {
3- CSS_EXTENSIONS_PATTERN ,
4- ENTRY_EXTENSIONS_PATTERN ,
5- JS_EXTENSIONS_PATTERN ,
6- } from '../src/constant' ;
2+ import { CSS_EXTENSIONS_PATTERN , DTS_EXTENSIONS_PATTERN , JS_EXTENSIONS_PATTERN } from '../src/constant' ;
73
84const jsTestStrings = [
95 { str : 'index.js' , expected : true } ,
@@ -25,6 +21,17 @@ const cssTestStrings = [
2521 { str : '/Users/path/index.sass' , expected : true } ,
2622] ;
2723
24+ const dtsTestStrings = [
25+ { str : 'index.js' , expected : false } ,
26+ { str : './index.ts' , expected : false } ,
27+ { str : './index.d.ts' , expected : true } ,
28+ { str : '/Users/path/index.ts' , expected : false } ,
29+ { str : '/Users/path/index.d.ts' , expected : true } ,
30+ { str : '/Users/path/index.d.mts' , expected : true } ,
31+ { str : '/Users/path/index.d.cts' , expected : true } ,
32+ { str : '/Users/path/index.tsx' , expected : false } ,
33+ ] ;
34+
2835test ( 'JS_EXTENSIONS_PATTERN' , ( ) => {
2936 for ( const { str, expected } of jsTestStrings ) {
3037 expect ( JS_EXTENSIONS_PATTERN . test ( str ) ) . toBe ( expected ) ;
@@ -37,8 +44,8 @@ test('CSS_EXTENSIONS_PATTERN', () => {
3744 }
3845} ) ;
3946
40- test ( 'ENTRY_EXTENSIONS_PATTERN ' , ( ) => {
41- for ( const { str, expected } of [ ... jsTestStrings , ... cssTestStrings ] ) {
42- expect ( ENTRY_EXTENSIONS_PATTERN . test ( str ) ) . toBe ( expected ) ;
47+ test ( 'DTS_EXTENSIONS_PATTERN ' , ( ) => {
48+ for ( const { str, expected } of dtsTestStrings ) {
49+ expect ( DTS_EXTENSIONS_PATTERN . test ( str ) ) . toBe ( expected ) ;
4350 }
4451} ) ;
0 commit comments