@@ -3,8 +3,11 @@ import path from 'path';
3
3
import { Configuration } from 'webpack' ;
4
4
import getConfig from '../config' ;
5
5
6
+ const testComponent = ( name : string ) => path . resolve ( __dirname , '../../../test/components' , name ) ;
7
+
6
8
const cwd = process . cwd ( ) ;
7
9
const configDir = path . resolve ( __dirname , '../../../test/apps/defaults' ) ;
10
+
8
11
beforeEach ( ( ) => {
9
12
process . chdir ( configDir ) ;
10
13
} ) ;
@@ -72,34 +75,32 @@ it('should have default getExampleFilename implementation', () => {
72
75
it ( 'default getExampleFilename should return Readme.md path if it exists' , ( ) => {
73
76
process . chdir ( '../..' ) ;
74
77
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')
77
80
) ;
78
81
} ) ;
79
82
80
83
it ( 'default getExampleFilename should return Component.md path if it exists' , ( ) => {
81
84
process . chdir ( '../..' ) ;
82
85
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')
85
88
) ;
86
89
} ) ;
87
90
88
91
it ( 'default getExampleFilename should return Component.md path if it exists with index.js' , ( ) => {
89
92
process . chdir ( '../..' ) ;
90
93
const result = getConfig ( ) ;
91
94
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')
94
97
) ;
95
98
} ) ;
96
99
97
100
it ( 'default getExampleFilename should return false if no examples file found' , ( ) => {
98
101
process . chdir ( '../..' ) ;
99
102
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 ( ) ;
103
104
} ) ;
104
105
105
106
it ( 'should have default getComponentPathLine implementation' , ( ) => {
0 commit comments