Skip to content

Commit b8c8610

Browse files
committed
test(exportfunctions): ensure backwards compatibility with FUNCTION_NAME
Previous update did not consider node 6 & 8 environments would still use FUNCTION_NAME. re #7
1 parent 956e52c commit b8c8610

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

__tests__/exportFunctions.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ describe('exportFunctions() function exporter test suite', () => {
3030
beforeEach(() => {
3131
jest.resetAllMocks();
3232
delete process.env.K_SERVICE;
33+
delete process.env.FUNCTION_NAME;
3334
});
3435

3536
beforeAll(() => {
@@ -87,14 +88,22 @@ describe('exportFunctions() function exporter test suite', () => {
8788
expect(testObj).toHaveProperty(filePathToPropertyPath(testFiles[1]), randOutput);
8889
});
8990

90-
it('should only extract one module when FUNCTION_NAME present', () => {
91+
it('should only extract one module when K_SERVICE present', () => {
9192
process.env.K_SERVICE = bff.funcNameFromRelPathDefault(testFiles[1]);
9293
const result = exportTestFactory({ enableLogger: true });
9394
expect(result).not.toHaveProperty(filePathToPropertyPath(testFiles[2]));
9495
expect(result).toHaveProperty(filePathToPropertyPath(testFiles[1]));
9596
expect(Object.keys(result)).toHaveLength(1);
9697
});
9798

99+
it('should only extract one module when FUNCTION_NAME present', () => {
100+
process.env.FUNCTION_NAME = bff.funcNameFromRelPathDefault(testFiles[1]);
101+
const result = exportTestFactory({ enableLogger: true });
102+
expect(result).not.toHaveProperty(filePathToPropertyPath(testFiles[2]));
103+
expect(result).toHaveProperty(filePathToPropertyPath(testFiles[1]));
104+
expect(Object.keys(result)).toHaveLength(1);
105+
});
106+
98107
it('will still work with glob match prepending ./ as in ./**/*.js', () => {
99108
expect(exportTestFactory({ searchGlob: './**/*.func.ts' })).toHaveProperty(filePathToPropertyPath(testFiles[1]));
100109
expect(exportTestFactory({ searchGlob: '**/*.func.ts' })).toHaveProperty(filePathToPropertyPath(testFiles[1]));

0 commit comments

Comments
 (0)