@@ -15,7 +15,7 @@ describe('ts-transform-asset', function () {
15
15
result : {
16
16
fullImport : string
17
17
defaultImport : string
18
- moduleImport : string
18
+ moduleImport : string | undefined
19
19
defaultExport : string
20
20
namedExport : string
21
21
}
@@ -26,7 +26,7 @@ describe('ts-transform-asset', function () {
26
26
result : {
27
27
fullImport : 'image.png' ,
28
28
defaultImport : 'image.svg' ,
29
- moduleImport : 'image .svg' ,
29
+ moduleImport : 'picture .svg' ,
30
30
defaultExport : 'image.svg' ,
31
31
namedExport : 'image.svg' ,
32
32
} ,
@@ -36,16 +36,17 @@ describe('ts-transform-asset', function () {
36
36
result : {
37
37
fullImport : 'assets/image.png' ,
38
38
defaultImport : 'assets/image.svg' ,
39
- moduleImport : 'assets/image .svg' ,
39
+ moduleImport : 'assets/picture .svg' ,
40
40
defaultExport : 'assets/image.svg' ,
41
41
namedExport : 'assets/image.svg' ,
42
42
} ,
43
43
} ,
44
44
default : {
45
+ rootDir : '__test__' ,
45
46
result : {
46
47
fullImport : '[hash].png' ,
47
48
defaultImport : 'b05767c238cb9f989cf3cd8180594878.svg' ,
48
- moduleImport : '[hash] .svg' ,
49
+ moduleImport : 'bee0f4fbbfd53e62289432b4a070cd03 .svg' ,
49
50
defaultExport : 'b05767c238cb9f989cf3cd8180594878.svg' ,
50
51
namedExport : 'b05767c238cb9f989cf3cd8180594878.svg' ,
51
52
} ,
@@ -56,7 +57,8 @@ describe('ts-transform-asset', function () {
56
57
result : {
57
58
fullImport : 'sub/folder/folder_[hash]-[contenthash].png' ,
58
59
defaultImport : '_b05767c238cb9f989cf3cd8180594878-b05767c238cb9f989cf3cd8180594878.svg' ,
59
- moduleImport : 'module/module_[hash]-[contenthash].svg' ,
60
+ moduleImport :
61
+ 'node_modules/dummy/dummy_bee0f4fbbfd53e62289432b4a070cd03-bee0f4fbbfd53e62289432b4a070cd03.svg' ,
60
62
defaultExport : '_b05767c238cb9f989cf3cd8180594878-b05767c238cb9f989cf3cd8180594878.svg' ,
61
63
namedExport : '_b05767c238cb9f989cf3cd8180594878-b05767c238cb9f989cf3cd8180594878.svg' ,
62
64
} ,
@@ -67,7 +69,7 @@ describe('ts-transform-asset', function () {
67
69
fullImport : '__test__/sub/folder/folder_[hash]-[contenthash].png' ,
68
70
defaultImport :
69
71
'__test__/__test___b05767c238cb9f989cf3cd8180594878-b05767c238cb9f989cf3cd8180594878.svg' ,
70
- moduleImport : '__test__/module/module_[hash]-[contenthash].svg' ,
72
+ moduleImport : undefined ,
71
73
defaultExport :
72
74
'__test__/__test___b05767c238cb9f989cf3cd8180594878-b05767c238cb9f989cf3cd8180594878.svg' ,
73
75
namedExport :
@@ -109,24 +111,30 @@ describe('ts-transform-asset', function () {
109
111
result . print ( )
110
112
} )
111
113
112
- it ( 'should find full module import file' , function ( ) {
113
- expect ( result . requireContent ( 'success' ) ( 'fullImport' ) ) . to . equal ( testCase . result . fullImport )
114
- } )
114
+ Array . of ( 'success' , 'package/success' ) . forEach ( file => {
115
+ describe ( `...in file ${ file } ` , function ( ) {
116
+ it ( 'should find full module import file' , function ( ) {
117
+ expect ( result . requireContent ( file ) ( 'fullImport' ) ) . to . equal ( testCase . result . fullImport )
118
+ } )
115
119
116
- it ( 'should find default module import file' , function ( ) {
117
- expect ( result . requireContent ( 'success' ) ( 'defaultImport' ) ) . to . equal ( testCase . result . defaultImport )
118
- } )
120
+ it ( 'should find default module import file' , function ( ) {
121
+ expect ( result . requireContent ( file ) ( 'defaultImport' ) ) . to . equal ( testCase . result . defaultImport )
122
+ } )
119
123
120
- it ( 'should find external module file' , function ( ) {
121
- expect ( result . requireContent ( 'success' ) ( 'moduleImport' ) ) . to . equal ( testCase . result . moduleImport )
122
- } )
124
+ if ( testCase . result . moduleImport ) {
125
+ it ( 'should find external module file' , function ( ) {
126
+ expect ( result . requireContent ( file ) ( 'moduleImport' ) ) . to . equal ( testCase . result . moduleImport )
127
+ } )
128
+ }
123
129
124
- it ( 'should find default re-exported file' , function ( ) {
125
- expect ( result . requireContent ( 'success' ) ( 'defaultExport' ) ) . to . equal ( testCase . result . defaultExport )
126
- } )
130
+ it ( 'should find default re-exported file' , function ( ) {
131
+ expect ( result . requireContent ( file ) ( 'defaultExport' ) ) . to . equal ( testCase . result . defaultExport )
132
+ } )
127
133
128
- it ( 'should find named re-exported file' , function ( ) {
129
- expect ( result . requireContent ( 'success' ) ( 'namedExport' ) ) . to . equal ( testCase . result . namedExport )
134
+ it ( 'should find named re-exported file' , function ( ) {
135
+ expect ( result . requireContent ( file ) ( 'namedExport' ) ) . to . equal ( testCase . result . namedExport )
136
+ } )
137
+ } )
130
138
} )
131
139
132
140
it ( 'should fail to require bad module' , function ( ) {
0 commit comments