Skip to content

Commit

Permalink
chore: Add another test
Browse files Browse the repository at this point in the history
  • Loading branch information
cansuaa committed Aug 7, 2024
1 parent d749c47 commit cdaf7f6
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions test/components/third-party-import-types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
import { buildProject } from './test-helpers';
import { ComponentDefinition } from '../../src';
import * as bootstrap from '../../src/bootstrap';
import process from 'node:process';
const cwd = process.cwd();
const nodeModulesPath = `${cwd}/fixtures/components/third-party-import-types/node_modules_mock/icon/interfaces.d.ts`;

test('should resolve object type to string', () => {
const resultBefore = buildProject('third-party-import-types');
Expand All @@ -24,9 +26,7 @@ test('should resolve object type to string', () => {
},
]);

const resultAfter = buildProject('third-party-import-types', [
`${cwd}/fixtures/components/third-party-import-types/node_modules_mock/icon/interfaces.d.ts`,
]);
const resultAfter = buildProject('third-party-import-types', [nodeModulesPath]);
const buttonAfter: ComponentDefinition | undefined = resultAfter.find(component => component.name === 'Button');

expect(buttonAfter?.properties).toEqual([
Expand All @@ -44,3 +44,13 @@ test('should resolve object type to string', () => {
},
]);
});

test('passing nodeModulesInputFilePaths should enable includeDeclarations and excludeExternals', () => {
const bootstrapProjectSpy = jest.spyOn(bootstrap, 'bootstrapProject');
buildProject('third-party-import-types', [nodeModulesPath]);

expect(bootstrapProjectSpy.mock.calls[0][0].includeDeclarations).toBe(true);
expect(bootstrapProjectSpy.mock.calls[0][0].excludeExternals).toBe(true);

jest.restoreAllMocks();
});

0 comments on commit cdaf7f6

Please sign in to comment.