Skip to content

Commit 669a917

Browse files
committed
test: Fix tests β€” no idea what happened here πŸ„
1 parent da8564a commit 669a917

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

β€Žsrc/scripts/__tests__/config.spec.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ import path from 'path';
33
import { Configuration } from 'webpack';
44
import getConfig from '../config';
55

6+
const testComponent = (name: string) => path.resolve(__dirname, '../../../test/components', name);
7+
68
const cwd = process.cwd();
79
const configDir = path.resolve(__dirname, '../../../test/apps/defaults');
10+
811
beforeEach(() => {
912
process.chdir(configDir);
1013
});
@@ -72,34 +75,32 @@ it('should have default getExampleFilename implementation', () => {
7275
it('default getExampleFilename should return Readme.md path if it exists', () => {
7376
process.chdir('../..');
7477
const result = getConfig();
75-
expect(result.getExampleFilename(path.resolve('components/Button/Button.js'))).toEqual(
76-
path.resolve('components/Button/Readme.md')
78+
expect(result.getExampleFilename(testComponent('Button/Button.js'))).toEqual(
79+
testComponent('Button/Readme.md')
7780
);
7881
});
7982

8083
it('default getExampleFilename should return Component.md path if it exists', () => {
8184
process.chdir('../..');
8285
const result = getConfig();
83-
expect(result.getExampleFilename(path.resolve('components/Placeholder/Placeholder.js'))).toEqual(
84-
path.resolve('components/Placeholder/Placeholder.md')
86+
expect(result.getExampleFilename(testComponent('Placeholder/Placeholder.js'))).toEqual(
87+
testComponent('Placeholder/Placeholder.md')
8588
);
8689
});
8790

8891
it('default getExampleFilename should return Component.md path if it exists with index.js', () => {
8992
process.chdir('../..');
9093
const result = getConfig();
9194
result.components = './components/**/*.js';
92-
expect(result.getExampleFilename(path.resolve('components/Label/index.js'))).toEqual(
93-
path.resolve('components/Label/Label.md')
95+
expect(result.getExampleFilename(testComponent('Label/Label.js'))).toEqual(
96+
testComponent('Label/Label.md')
9497
);
9598
});
9699

97100
it('default getExampleFilename should return false if no examples file found', () => {
98101
process.chdir('../..');
99102
const result = getConfig();
100-
expect(
101-
result.getExampleFilename(path.resolve('components/RandomButton/RandomButton.js'))
102-
).toBeFalsy();
103+
expect(result.getExampleFilename(testComponent('RandomButton/RandomButton.js'))).toBeFalsy();
103104
});
104105

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

0 commit comments

Comments
Β (0)