@@ -6,18 +6,18 @@ var rename = require('../');
6
6
var gulp = require ( 'gulp' ) ;
7
7
var Path = require ( 'path' ) ;
8
8
9
- describe ( 'gulp-rename' , function ( ) {
10
- context ( 'with string parameter' , function ( ) {
11
- context ( 'when src pattern does not contain directory glob' , function ( ) {
12
- it ( 'sets filename to value' , function ( done ) {
9
+ describe ( 'gulp-rename' , function ( ) {
10
+ context ( 'with string parameter' , function ( ) {
11
+ context ( 'when src pattern does not contain directory glob' , function ( ) {
12
+ it ( 'sets filename to value' , function ( done ) {
13
13
var srcPattern = 'test/fixtures/hello.txt' ;
14
14
var obj = 'hola.md' ;
15
15
var expectedPath = 'test/fixtures/hola.md' ;
16
16
helper ( srcPattern , obj , expectedPath , done ) ;
17
17
} ) ;
18
18
} ) ;
19
- context ( 'when src pattern contains directory glob' , function ( ) {
20
- it ( 'sets relative path to value' , function ( done ) {
19
+ context ( 'when src pattern contains directory glob' , function ( ) {
20
+ it ( 'sets relative path to value' , function ( done ) {
21
21
var srcPattern = 'test/**/hello.txt' ;
22
22
var obj = 'fixtures/hola.md' ;
23
23
var expectedPath = 'test/fixtures/hola.md' ;
@@ -26,135 +26,135 @@ describe('gulp-rename', function () {
26
26
} ) ;
27
27
} ) ;
28
28
29
- context ( 'with object parameter' , function ( ) {
29
+ context ( 'with object parameter' , function ( ) {
30
30
var srcPattern ;
31
- beforeEach ( function ( ) {
31
+ beforeEach ( function ( ) {
32
32
srcPattern = 'test/**/hello.txt' ;
33
33
} ) ;
34
34
35
- context ( 'with empty object' , function ( ) {
36
- it ( 'has no effect' , function ( done ) {
35
+ context ( 'with empty object' , function ( ) {
36
+ it ( 'has no effect' , function ( done ) {
37
37
var obj = { } ;
38
38
var expectedPath = 'test/fixtures/hello.txt' ;
39
39
helper ( srcPattern , obj , expectedPath , done ) ;
40
40
} ) ;
41
41
} ) ;
42
42
43
- context ( 'with dirname value' , function ( ) {
44
- it ( 'replaces dirname with value' , function ( done ) {
43
+ context ( 'with dirname value' , function ( ) {
44
+ it ( 'replaces dirname with value' , function ( done ) {
45
45
var obj = {
46
- dirname : 'elsewhere' ,
46
+ dirname : 'elsewhere'
47
47
} ;
48
48
var expectedPath = 'test/elsewhere/hello.txt' ;
49
49
helper ( srcPattern , obj , expectedPath , done ) ;
50
50
} ) ;
51
- it ( ' removes dirname with \ './\'' , function ( done ) {
51
+ it ( " removes dirname with './'" , function ( done ) {
52
52
var obj = {
53
- dirname : './' ,
53
+ dirname : './'
54
54
} ;
55
55
var expectedPath = 'test/hello.txt' ;
56
56
helper ( srcPattern , obj , expectedPath , done ) ;
57
57
} ) ;
58
- it ( 'removes dirname with empty string' , function ( done ) {
58
+ it ( 'removes dirname with empty string' , function ( done ) {
59
59
var obj = {
60
- dirname : '' ,
60
+ dirname : ''
61
61
} ;
62
62
var expectedPath = 'test/hello.txt' ;
63
63
helper ( srcPattern , obj , expectedPath , done ) ;
64
64
} ) ;
65
65
} ) ;
66
66
67
- context ( 'with prefix value' , function ( ) {
68
- it ( 'prepends value to basename' , function ( done ) {
67
+ context ( 'with prefix value' , function ( ) {
68
+ it ( 'prepends value to basename' , function ( done ) {
69
69
var obj = {
70
- prefix : 'bonjour-' ,
70
+ prefix : 'bonjour-'
71
71
} ;
72
72
var expectedPath = 'test/fixtures/bonjour-hello.txt' ;
73
73
helper ( srcPattern , obj , expectedPath , done ) ;
74
74
} ) ;
75
75
} ) ;
76
76
77
- context ( 'with basename value' , function ( ) {
78
- it ( 'replaces basename with value' , function ( done ) {
77
+ context ( 'with basename value' , function ( ) {
78
+ it ( 'replaces basename with value' , function ( done ) {
79
79
var obj = {
80
- basename : 'aloha' ,
80
+ basename : 'aloha'
81
81
} ;
82
82
var expectedPath = 'test/fixtures/aloha.txt' ;
83
83
helper ( srcPattern , obj , expectedPath , done ) ;
84
84
} ) ;
85
- it ( 'removes basename with empty string (for consistency)' , function ( done ) {
85
+ it ( 'removes basename with empty string (for consistency)' , function ( done ) {
86
86
var obj = {
87
87
prefix : 'aloha' ,
88
- basename : '' ,
88
+ basename : ''
89
89
} ;
90
90
var expectedPath = 'test/fixtures/aloha.txt' ;
91
91
helper ( srcPattern , obj , expectedPath , done ) ;
92
92
} ) ;
93
93
} ) ;
94
94
95
- context ( 'with suffix value' , function ( ) {
96
- it ( 'appends value to basename' , function ( done ) {
95
+ context ( 'with suffix value' , function ( ) {
96
+ it ( 'appends value to basename' , function ( done ) {
97
97
var obj = {
98
- suffix : '-hola' ,
98
+ suffix : '-hola'
99
99
} ;
100
100
var expectedPath = 'test/fixtures/hello-hola.txt' ;
101
101
helper ( srcPattern , obj , expectedPath , done ) ;
102
102
} ) ;
103
103
} ) ;
104
104
105
- context ( 'with extname value' , function ( ) {
106
- it ( 'replaces extname with value' , function ( done ) {
105
+ context ( 'with extname value' , function ( ) {
106
+ it ( 'replaces extname with value' , function ( done ) {
107
107
var obj = {
108
- extname : '.md' ,
108
+ extname : '.md'
109
109
} ;
110
110
var expectedPath = 'test/fixtures/hello.md' ;
111
111
helper ( srcPattern , obj , expectedPath , done ) ;
112
112
} ) ;
113
- it ( 'removes extname with empty string' , function ( done ) {
113
+ it ( 'removes extname with empty string' , function ( done ) {
114
114
var obj = {
115
- extname : '' ,
115
+ extname : ''
116
116
} ;
117
117
var expectedPath = 'test/fixtures/hello' ;
118
118
helper ( srcPattern , obj , expectedPath , done ) ;
119
119
} ) ;
120
120
} ) ;
121
121
} ) ;
122
122
123
- context ( 'with function parameter' , function ( ) {
123
+ context ( 'with function parameter' , function ( ) {
124
124
var srcPattern ;
125
- beforeEach ( function ( ) {
125
+ beforeEach ( function ( ) {
126
126
srcPattern = 'test/**/hello.txt' ;
127
127
} ) ;
128
128
129
- it ( 'receives object with dirname' , function ( done ) {
130
- var obj = function ( path ) {
129
+ it ( 'receives object with dirname' , function ( done ) {
130
+ var obj = function ( path ) {
131
131
path . dirname . should . equal ( 'fixtures' ) ;
132
132
path . dirname = 'elsewhere' ;
133
133
} ;
134
134
var expectedPath = 'test/elsewhere/hello.txt' ;
135
135
helper ( srcPattern , obj , expectedPath , done ) ;
136
136
} ) ;
137
137
138
- it ( 'receives object with basename' , function ( done ) {
139
- var obj = function ( path ) {
138
+ it ( 'receives object with basename' , function ( done ) {
139
+ var obj = function ( path ) {
140
140
path . basename . should . equal ( 'hello' ) ;
141
141
path . basename = 'aloha' ;
142
142
} ;
143
143
var expectedPath = 'test/fixtures/aloha.txt' ;
144
144
helper ( srcPattern , obj , expectedPath , done ) ;
145
145
} ) ;
146
146
147
- it ( 'receives object with extname' , function ( done ) {
148
- var obj = function ( path ) {
147
+ it ( 'receives object with extname' , function ( done ) {
148
+ var obj = function ( path ) {
149
149
path . extname . should . equal ( '.txt' ) ;
150
150
path . extname = '.md' ;
151
151
} ;
152
152
var expectedPath = 'test/fixtures/hello.md' ;
153
153
helper ( srcPattern , obj , expectedPath , done ) ;
154
154
} ) ;
155
155
156
- it ( 'receives object from return value' , function ( done ) {
157
- var obj = function ( path ) {
156
+ it ( 'receives object from return value' , function ( done ) {
157
+ var obj = function ( path ) {
158
158
return {
159
159
dirname : path . dirname ,
160
160
basename : path . basename ,
@@ -165,8 +165,8 @@ describe('gulp-rename', function () {
165
165
helper ( srcPattern , obj , expectedPath , done ) ;
166
166
} ) ;
167
167
168
- it ( 'ignores null return value but uses passed object' , function ( done ) {
169
- var obj = function ( path ) {
168
+ it ( 'ignores null return value but uses passed object' , function ( done ) {
169
+ var obj = function ( path ) {
170
170
path . extname . should . equal ( '.txt' ) ;
171
171
path . extname = '.md' ;
172
172
return null ;
@@ -175,8 +175,8 @@ describe('gulp-rename', function () {
175
175
helper ( srcPattern , obj , expectedPath , done ) ;
176
176
} ) ;
177
177
178
- it ( 'receives object with extname even if a different value is returned' , function ( done ) {
179
- var obj = function ( path ) {
178
+ it ( 'receives object with extname even if a different value is returned' , function ( done ) {
179
+ var obj = function ( path ) {
180
180
path . extname . should . equal ( '.txt' ) ;
181
181
path . extname = '.md' ;
182
182
} ;
@@ -185,12 +185,12 @@ describe('gulp-rename', function () {
185
185
} ) ;
186
186
} ) ;
187
187
188
- context ( 'in parallel streams' , function ( ) {
189
- it ( 'only changes the file in the current stream' , function ( done ) {
188
+ context ( 'in parallel streams' , function ( ) {
189
+ it ( 'only changes the file in the current stream' , function ( done ) {
190
190
var files = gulp . src ( 'test/fixtures/hello.txt' ) ;
191
191
192
- var pipe1 = files . pipe ( rename ( { suffix : '-1' } ) ) ;
193
- var pipe2 = files . pipe ( rename ( { suffix : '-2' } ) ) ;
192
+ var pipe1 = files . pipe ( rename ( { suffix : '-1' } ) ) ;
193
+ var pipe2 = files . pipe ( rename ( { suffix : '-2' } ) ) ;
194
194
var end1 = false ;
195
195
var end2 = false ;
196
196
var file1 ;
@@ -204,10 +204,10 @@ describe('gulp-rename', function () {
204
204
}
205
205
206
206
pipe1
207
- . on ( 'data' , function ( file ) {
207
+ . on ( 'data' , function ( file ) {
208
208
file1 = file ;
209
209
} )
210
- . on ( 'end' , function ( ) {
210
+ . on ( 'end' , function ( ) {
211
211
end1 = true ;
212
212
213
213
if ( end2 ) {
@@ -216,10 +216,10 @@ describe('gulp-rename', function () {
216
216
} ) ;
217
217
218
218
pipe2
219
- . on ( 'data' , function ( file ) {
219
+ . on ( 'data' , function ( file ) {
220
220
file2 = file ;
221
221
} )
222
- . on ( 'end' , function ( ) {
222
+ . on ( 'end' , function ( ) {
223
223
end2 = true ;
224
224
225
225
if ( end1 ) {
@@ -229,38 +229,38 @@ describe('gulp-rename', function () {
229
229
} ) ;
230
230
} ) ;
231
231
232
- context ( 'throws unsupported parameter type' , function ( ) {
232
+ context ( 'throws unsupported parameter type' , function ( ) {
233
233
var srcPattern ;
234
- beforeEach ( function ( ) {
234
+ beforeEach ( function ( ) {
235
235
srcPattern = 'test/**/hello.txt' ;
236
236
} ) ;
237
237
238
238
var UNSUPPORTED_PARAMATER = 'Unsupported renaming parameter type supplied' ;
239
- it ( 'with undefined object' , function ( done ) {
239
+ it ( 'with undefined object' , function ( done ) {
240
240
var obj ;
241
241
var expectedError = UNSUPPORTED_PARAMATER ;
242
242
helperError ( srcPattern , obj , expectedError , done ) ;
243
243
} ) ;
244
244
245
- it ( 'with null object' , function ( done ) {
245
+ it ( 'with null object' , function ( done ) {
246
246
var obj = null ;
247
247
var expectedError = UNSUPPORTED_PARAMATER ;
248
248
helperError ( srcPattern , obj , expectedError , done ) ;
249
249
} ) ;
250
250
251
- it ( 'with empty string' , function ( done ) {
251
+ it ( 'with empty string' , function ( done ) {
252
252
var obj = '' ;
253
253
var expectedError = UNSUPPORTED_PARAMATER ;
254
254
helperError ( srcPattern , obj , expectedError , done ) ;
255
255
} ) ;
256
256
257
- it ( 'with boolean value' , function ( done ) {
257
+ it ( 'with boolean value' , function ( done ) {
258
258
var obj = true ;
259
259
var expectedError = UNSUPPORTED_PARAMATER ;
260
260
helperError ( srcPattern , obj , expectedError , done ) ;
261
261
} ) ;
262
262
263
- it ( 'with numeric value' , function ( done ) {
263
+ it ( 'with numeric value' , function ( done ) {
264
264
var obj = 1 ;
265
265
var expectedError = UNSUPPORTED_PARAMATER ;
266
266
helperError ( srcPattern , obj , expectedError , done ) ;
0 commit comments