Skip to content

Commit

Permalink
test: Fix tests β€” no idea what happened here πŸ„
Browse files Browse the repository at this point in the history
  • Loading branch information
sapegin committed Oct 23, 2020
1 parent da8564a commit 669a917
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/scripts/__tests__/config.spec.ts
Expand Up @@ -3,8 +3,11 @@ import path from 'path';
import { Configuration } from 'webpack';
import getConfig from '../config';

const testComponent = (name: string) => path.resolve(__dirname, '../../../test/components', name);

const cwd = process.cwd();
const configDir = path.resolve(__dirname, '../../../test/apps/defaults');

beforeEach(() => {
process.chdir(configDir);
});
Expand Down Expand Up @@ -72,34 +75,32 @@ it('should have default getExampleFilename implementation', () => {
it('default getExampleFilename should return Readme.md path if it exists', () => {
process.chdir('../..');
const result = getConfig();
expect(result.getExampleFilename(path.resolve('components/Button/Button.js'))).toEqual(
path.resolve('components/Button/Readme.md')
expect(result.getExampleFilename(testComponent('Button/Button.js'))).toEqual(
testComponent('Button/Readme.md')
);
});

it('default getExampleFilename should return Component.md path if it exists', () => {
process.chdir('../..');
const result = getConfig();
expect(result.getExampleFilename(path.resolve('components/Placeholder/Placeholder.js'))).toEqual(
path.resolve('components/Placeholder/Placeholder.md')
expect(result.getExampleFilename(testComponent('Placeholder/Placeholder.js'))).toEqual(
testComponent('Placeholder/Placeholder.md')
);
});

it('default getExampleFilename should return Component.md path if it exists with index.js', () => {
process.chdir('../..');
const result = getConfig();
result.components = './components/**/*.js';
expect(result.getExampleFilename(path.resolve('components/Label/index.js'))).toEqual(
path.resolve('components/Label/Label.md')
expect(result.getExampleFilename(testComponent('Label/Label.js'))).toEqual(
testComponent('Label/Label.md')
);
});

it('default getExampleFilename should return false if no examples file found', () => {
process.chdir('../..');
const result = getConfig();
expect(
result.getExampleFilename(path.resolve('components/RandomButton/RandomButton.js'))
).toBeFalsy();
expect(result.getExampleFilename(testComponent('RandomButton/RandomButton.js'))).toBeFalsy();
});

it('should have default getComponentPathLine implementation', () => {
Expand Down

0 comments on commit 669a917

Please sign in to comment.