Skip to content

Commit 421366e

Browse files
committed
test(exportfunctions): test that the {js,ts} new glob search default works as expected
1 parent 362ceab commit 421366e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

__tests__/exportFunctions.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ describe('exportFunctions() function exporter test suite', () => {
2020
'folder/new.func.ts',
2121
'folder/not-a-func.ts',
2222
'folder/nestedFolder/sample-func.func.ts',
23+
'folder/nestedFolder/sample-js-func.func.js',
2324
];
2425
const { name: tempFuncDir } = tmp.dirSync();
2526
const randOutput = Math.floor(Math.random() * 10);
@@ -49,7 +50,7 @@ describe('exportFunctions() function exporter test suite', () => {
4950
__dirname: tempFuncDir,
5051
__filename: `${tempFuncDir}/pretend-index.ts`,
5152
exports: {},
52-
searchGlob: '**/*.func.ts',
53+
searchGlob: '**/*.func.{ts,js}',
5354
...configObj,
5455
});
5556

@@ -62,9 +63,9 @@ describe('exportFunctions() function exporter test suite', () => {
6263
});
6364

6465
it('should properly nest submodules found in directories', () => {
65-
expect(exportTestFactory()).toHaveProperty(filePathToPropertyPath(testFiles[4]), randOutput);
66-
expect(exportTestFactory()).not.toHaveProperty(filePathToPropertyPath(testFiles[3]), randOutput);
67-
expect(exportTestFactory()).toHaveProperty(filePathToPropertyPath(testFiles[6]), randOutput);
66+
expect(exportTestFactory()).toHaveProperty(filePathToPropertyPath(testFiles[4]), randOutput); // func
67+
expect(exportTestFactory()).not.toHaveProperty(filePathToPropertyPath(testFiles[3]), randOutput); // empty folder
68+
expect(exportTestFactory()).toHaveProperty(filePathToPropertyPath(testFiles[6]), randOutput); // nested func
6869
});
6970

7071
it('should correctly apply camelCase to kebab-case named files', () => {
@@ -116,4 +117,9 @@ describe('exportFunctions() function exporter test suite', () => {
116117
console.log(output);
117118
expect(output).toHaveProperty(filePathToPropertyPath(testFiles[4]), testFiles[4]);
118119
});
120+
121+
it('can detect both js and ts files using updated glob search - new default', () => {
122+
const output = exportTestFactory({ exportPathMode: true });
123+
expect(output).toHaveProperty(filePathToPropertyPath(testFiles[7]), testFiles[7]); // js file
124+
});
119125
});

0 commit comments

Comments
 (0)