@@ -5,7 +5,7 @@ import { runEmit } from './helpers/run';
5
5
const FIXTURES_DIR = path . join ( __dirname , 'fixtures' ) ;
6
6
7
7
describe ( 'context option' , ( ) => {
8
- it ( 'should work when "from" is a file' , ( done ) => {
8
+ it ( 'should work when "from" is a file and "context" is a relative path ' , ( done ) => {
9
9
runEmit ( {
10
10
expectedAssetKeys : [ 'directoryfile.txt' ] ,
11
11
patterns : [
@@ -19,26 +19,29 @@ describe('context option', () => {
19
19
. catch ( done ) ;
20
20
} ) ;
21
21
22
- it ( 'should work when "from" is a file and "context" with special characters ' , ( done ) => {
22
+ it ( 'should work when "from" is a directory and "context" is a relative path ' , ( done ) => {
23
23
runEmit ( {
24
- expectedAssetKeys : [ 'directoryfile .txt' ] ,
24
+ expectedAssetKeys : [ 'deep-nested/deepnested.txt' , 'nestedfile .txt'] ,
25
25
patterns : [
26
26
{
27
- from : 'directoryfile.txt ' ,
28
- context : '[special? directory] ' ,
27
+ from : 'nested ' ,
28
+ context : 'directory' ,
29
29
} ,
30
30
] ,
31
31
} )
32
32
. then ( done )
33
33
. catch ( done ) ;
34
34
} ) ;
35
35
36
- it ( 'should work when "from" is a directory ' , ( done ) => {
36
+ it ( 'should work when "from" is a glob and "context" is a relative path ' , ( done ) => {
37
37
runEmit ( {
38
- expectedAssetKeys : [ 'deep-nested/deepnested.txt' , 'nestedfile.txt' ] ,
38
+ expectedAssetKeys : [
39
+ 'nested/deep-nested/deepnested.txt' ,
40
+ 'nested/nestedfile.txt' ,
41
+ ] ,
39
42
patterns : [
40
43
{
41
- from : 'nested' ,
44
+ from : 'nested/**/* ' ,
42
45
context : 'directory' ,
43
46
} ,
44
47
] ,
@@ -47,44 +50,35 @@ describe('context option', () => {
47
50
. catch ( done ) ;
48
51
} ) ;
49
52
50
- it ( 'should work when "from" is a directory and "to " is a new directory ' , ( done ) => {
53
+ it ( 'should work when "from" is a file and "context " is an absolute path ' , ( done ) => {
51
54
runEmit ( {
52
- expectedAssetKeys : [
53
- 'newdirectory/deep-nested/deepnested.txt' ,
54
- 'newdirectory/nestedfile.txt' ,
55
- ] ,
55
+ expectedAssetKeys : [ 'directoryfile.txt' ] ,
56
56
patterns : [
57
57
{
58
- context : 'directory' ,
59
- from : 'nested' ,
60
- to : 'newdirectory' ,
58
+ from : 'directoryfile.txt' ,
59
+ context : path . join ( FIXTURES_DIR , 'directory' ) ,
61
60
} ,
62
61
] ,
63
62
} )
64
63
. then ( done )
65
64
. catch ( done ) ;
66
65
} ) ;
67
66
68
- it ( 'should work when "from" is a directory and "context" with special characters ' , ( done ) => {
67
+ it ( 'should work when "from" is a directory and "context" is an absolute path ' , ( done ) => {
69
68
runEmit ( {
70
- expectedAssetKeys : [
71
- 'directoryfile.txt' ,
72
- '(special-*file).txt' ,
73
- 'nested/nestedfile.txt' ,
74
- ] ,
69
+ expectedAssetKeys : [ 'deep-nested/deepnested.txt' , 'nestedfile.txt' ] ,
75
70
patterns : [
76
71
{
77
- // Todo strange behavour when you use `FIXTURES_DIR`, need investigate for next major release
78
- from : '.' ,
79
- context : '[special?directory]' ,
72
+ from : 'nested' ,
73
+ context : path . join ( FIXTURES_DIR , 'directory' ) ,
80
74
} ,
81
75
] ,
82
76
} )
83
77
. then ( done )
84
78
. catch ( done ) ;
85
79
} ) ;
86
80
87
- it ( 'should work when "from" is a glob' , ( done ) => {
81
+ it ( 'should work when "from" is a glob and "context" is an absolute path ' , ( done ) => {
88
82
runEmit ( {
89
83
expectedAssetKeys : [
90
84
'nested/deep-nested/deepnested.txt' ,
@@ -93,45 +87,40 @@ describe('context option', () => {
93
87
patterns : [
94
88
{
95
89
from : 'nested/**/*' ,
96
- context : 'directory' ,
90
+ context : path . join ( FIXTURES_DIR , 'directory' ) ,
97
91
} ,
98
92
] ,
99
93
} )
100
94
. then ( done )
101
95
. catch ( done ) ;
102
96
} ) ;
103
97
104
- it ( 'should work when "from" is a glob and "to" is a directory ' , ( done ) => {
98
+ it ( 'should work when "from" is a file and "context" with special characters ' , ( done ) => {
105
99
runEmit ( {
106
- expectedAssetKeys : [
107
- 'nested/directoryfile.txt' ,
108
- 'nested/nested/deep-nested/deepnested.txt' ,
109
- 'nested/nested/nestedfile.txt' ,
110
- ] ,
100
+ expectedAssetKeys : [ 'directoryfile.txt' ] ,
111
101
patterns : [
112
102
{
113
- context : 'directory' ,
114
- from : '**/*' ,
115
- to : 'nested' ,
103
+ from : 'directoryfile.txt' ,
104
+ context : '[special?directory]' ,
116
105
} ,
117
106
] ,
118
107
} )
119
108
. then ( done )
120
109
. catch ( done ) ;
121
110
} ) ;
122
111
123
- it ( 'should work when "from" is a glob and "to" is a directory and "content" is an absolute path ' , ( done ) => {
112
+ it ( 'should work when "from" is a directory and "context" with special characters ' , ( done ) => {
124
113
runEmit ( {
125
114
expectedAssetKeys : [
126
- 'nested/ directoryfile.txt' ,
127
- 'nested/nested/deep-nested/deepnested .txt' ,
128
- 'nested/nested/ nestedfile.txt' ,
115
+ 'directoryfile.txt' ,
116
+ '(special-*file) .txt' ,
117
+ 'nested/nestedfile.txt' ,
129
118
] ,
130
119
patterns : [
131
120
{
132
- context : path . join ( FIXTURES_DIR , 'directory' ) ,
133
- from : '**/* ' ,
134
- to : 'nested ' ,
121
+ // Todo strange behavour when you use ` FIXTURES_DIR`, need investigate for next major release
122
+ from : '. ' ,
123
+ context : '[special?directory] ' ,
135
124
} ,
136
125
] ,
137
126
} )
@@ -171,32 +160,13 @@ describe('context option', () => {
171
160
. catch ( done ) ;
172
161
} ) ;
173
162
174
- it ( 'should work when "from" is a file and "context " is an absolute path ' , ( done ) => {
163
+ it ( 'should work when "from" is a file and "to " is a directory ' , ( done ) => {
175
164
runEmit ( {
176
- expectedAssetKeys : [ 'directoryfile.txt' ] ,
165
+ expectedAssetKeys : [ 'newdirectory/ directoryfile.txt' ] ,
177
166
patterns : [
178
167
{
168
+ context : 'directory' ,
179
169
from : 'directoryfile.txt' ,
180
- context : path . join ( FIXTURES_DIR , 'directory' ) ,
181
- } ,
182
- ] ,
183
- } )
184
- . then ( done )
185
- . catch ( done ) ;
186
- } ) ;
187
-
188
- it ( 'should override webpack config context with an absolute path' , ( done ) => {
189
- runEmit ( {
190
- expectedAssetKeys : [
191
- 'newdirectory/deep-nested/deepnested.txt' ,
192
- 'newdirectory/nestedfile.txt' ,
193
- ] ,
194
- options : {
195
- context : path . join ( FIXTURES_DIR , 'directory' ) ,
196
- } ,
197
- patterns : [
198
- {
199
- from : 'nested' ,
200
170
to : 'newdirectory' ,
201
171
} ,
202
172
] ,
@@ -205,17 +175,15 @@ describe('context option', () => {
205
175
. catch ( done ) ;
206
176
} ) ;
207
177
208
- it ( 'should override webpack config context with a relative path ' , ( done ) => {
178
+ it ( 'should work when "from" is a directory and "to" is a directory ' , ( done ) => {
209
179
runEmit ( {
210
180
expectedAssetKeys : [
211
181
'newdirectory/deep-nested/deepnested.txt' ,
212
182
'newdirectory/nestedfile.txt' ,
213
183
] ,
214
- options : {
215
- context : 'directory' ,
216
- } ,
217
184
patterns : [
218
185
{
186
+ context : 'directory' ,
219
187
from : 'nested' ,
220
188
to : 'newdirectory' ,
221
189
} ,
@@ -225,41 +193,18 @@ describe('context option', () => {
225
193
. catch ( done ) ;
226
194
} ) ;
227
195
228
- it ( 'should override global context on pattern context with a relative path' , ( done ) => {
229
- runEmit ( {
230
- expectedAssetKeys : [
231
- 'newdirectory/deep-nested/deepnested.txt' ,
232
- 'newdirectory/nestedfile.txt' ,
233
- ] ,
234
- options : {
235
- context : 'directory' ,
236
- } ,
237
- patterns : [
238
- {
239
- context : 'nested' ,
240
- from : '.' ,
241
- to : 'newdirectory' ,
242
- } ,
243
- ] ,
244
- } )
245
- . then ( done )
246
- . catch ( done ) ;
247
- } ) ;
248
-
249
- it ( 'overrides webpack config context with an absolute path' , ( done ) => {
196
+ it ( 'should work when "from" is a glob and "to" is a directory' , ( done ) => {
250
197
runEmit ( {
251
198
expectedAssetKeys : [
252
- 'newdirectory/file .txt' ,
253
- 'newdirectory/nesteddir/deepnesteddir/deepnesteddir .txt' ,
254
- 'newdirectory/nesteddir /nestedfile.txt' ,
199
+ 'nested/directoryfile .txt' ,
200
+ 'nested/nested/deep-nested/deepnested .txt' ,
201
+ 'nested/nested /nestedfile.txt' ,
255
202
] ,
256
- options : {
257
- context : path . join ( FIXTURES_DIR , 'dir (86)' ) ,
258
- } ,
259
203
patterns : [
260
204
{
205
+ context : 'directory' ,
261
206
from : '**/*' ,
262
- to : 'newdirectory ' ,
207
+ to : 'nested ' ,
263
208
} ,
264
209
] ,
265
210
} )
0 commit comments