mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-04 19:51:08 +08:00
33 lines
801 B
JavaScript
33 lines
801 B
JavaScript
import loadTsConfig from './ts_config';
|
|
|
|
// eslint-disable-next-line global-require
|
|
jest.mock('fs', () => require('../../../../__mocks__/fs'));
|
|
jest.mock('path', () => ({
|
|
resolve: () => 'tsconfig.json',
|
|
}));
|
|
|
|
const setupFiles = files => {
|
|
// eslint-disable-next-line no-underscore-dangle, global-require
|
|
require('fs').__setMockFiles(files);
|
|
};
|
|
|
|
describe('ts_config', () => {
|
|
it('should return the config with the path to the tsconfig.json', () => {
|
|
setupFiles({ 'tsconfig.json': '{}' });
|
|
|
|
const config = loadTsConfig('.foo');
|
|
|
|
expect(config).toEqual({
|
|
configFile: 'tsconfig.json',
|
|
});
|
|
});
|
|
|
|
it('should return empty object when there is no tsconfig.json', () => {
|
|
setupFiles({});
|
|
|
|
const config = loadTsConfig('.foo');
|
|
|
|
expect(config).toEqual({});
|
|
});
|
|
});
|