@@ -3,8 +3,11 @@ import path from 'path';
33import { Configuration } from 'webpack' ;
44import getConfig from '../config' ;
55
6+ const testComponent = ( name : string ) => path . resolve ( __dirname , '../../../test/components' , name ) ;
7+
68const cwd = process . cwd ( ) ;
79const configDir = path . resolve ( __dirname , '../../../test/apps/defaults' ) ;
10+
811beforeEach ( ( ) => {
912 process . chdir ( configDir ) ;
1013} ) ;
@@ -72,34 +75,32 @@ it('should have default getExampleFilename implementation', () => {
7275it ( '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
8083it ( '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
8891it ( '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
97100it ( '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
105106it ( 'should have default getComponentPathLine implementation' , ( ) => {
0 commit comments