|
4 | 4 | require('./spec-helper');
|
5 | 5 | var Path = require('path');
|
6 | 6 |
|
7 |
| -describe('gulp-rename path parsing', function () { |
8 |
| - describe('dirname', function () { |
9 |
| - context('when src pattern contains no globs', function () { |
10 |
| - it('dirname is \'.\'', function (done) { |
| 7 | +describe('gulp-rename path parsing', function() { |
| 8 | + describe('dirname', function() { |
| 9 | + context('when src pattern contains no globs', function() { |
| 10 | + it("dirname is '.'", function(done) { |
11 | 11 | var srcPattern = 'test/fixtures/hello.txt';
|
12 |
| - var obj = function (path) { |
| 12 | + var obj = function(path) { |
13 | 13 | path.dirname.should.equal('.');
|
14 | 14 | };
|
15 | 15 | helper(srcPattern, obj, null, done);
|
16 | 16 | });
|
17 | 17 | });
|
18 | 18 |
|
19 |
| - context('when src pattern contains filename glob', function () { |
20 |
| - it('dirname is \'.\'', function (done) { |
| 19 | + context('when src pattern contains filename glob', function() { |
| 20 | + it("dirname is '.'", function(done) { |
21 | 21 | var srcPattern = 'test/fixtures/*.min.txt';
|
22 |
| - var obj = function (path) { |
| 22 | + var obj = function(path) { |
23 | 23 | path.dirname.should.equal('.');
|
24 | 24 | };
|
25 | 25 | helper(srcPattern, obj, null, done);
|
26 | 26 | });
|
27 | 27 | });
|
28 | 28 |
|
29 |
| - var dirnameHelper = function (srcPattern) { |
30 |
| - it('dirname is path from directory glob to file', function (done) { |
31 |
| - var obj = function (path) { |
| 29 | + var dirnameHelper = function(srcPattern) { |
| 30 | + it('dirname is path from directory glob to file', function(done) { |
| 31 | + var obj = function(path) { |
32 | 32 | path.dirname.should.match(/^fixtures[0-9]?$/);
|
33 | 33 | };
|
34 | 34 | helper(srcPattern, obj, null, done);
|
35 | 35 | });
|
36 | 36 | };
|
37 | 37 |
|
38 |
| - context('when src pattern matches a directory with *', function () { |
| 38 | + context('when src pattern matches a directory with *', function() { |
39 | 39 | dirnameHelper('test/*/*.min.txt');
|
40 | 40 | });
|
41 | 41 |
|
42 |
| - context('when src pattern matches a directory with **', function () { |
| 42 | + context('when src pattern matches a directory with **', function() { |
43 | 43 | dirnameHelper('test/**/*.min.txt');
|
44 | 44 | });
|
45 | 45 |
|
46 |
| - context('when src pattern matches a directory with [...]', function () { |
| 46 | + context('when src pattern matches a directory with [...]', function() { |
47 | 47 | dirnameHelper('test/fixt[a-z]res/*.min.txt');
|
48 | 48 | });
|
49 | 49 |
|
50 |
| - context('when src pattern matches a directory with {...,...}', function () { |
| 50 | + context('when src pattern matches a directory with {...,...}', function() { |
51 | 51 | dirnameHelper('test/f{ri,ixtur}es/*.min.txt');
|
52 | 52 | });
|
53 | 53 |
|
54 | 54 | /* SKIP: glob2base does not handle brace expansion as expected. See wearefractal/glob2base#1 */
|
55 |
| - context.skip('when src pattern matches a directory with {#..#}', function () { |
56 |
| - dirnameHelper('test/fixtures{0..9}/*.min.txt'); |
57 |
| - }); |
58 |
| - |
59 |
| - context('when src pattern matches a directory with an extglob', function () { |
| 55 | + context.skip( |
| 56 | + 'when src pattern matches a directory with {#..#}', |
| 57 | + function() { |
| 58 | + dirnameHelper('test/fixtures{0..9}/*.min.txt'); |
| 59 | + } |
| 60 | + ); |
| 61 | + |
| 62 | + context('when src pattern matches a directory with an extglob', function() { |
60 | 63 | dirnameHelper('test/f+(ri|ixtur)es/*.min.txt');
|
61 | 64 | });
|
62 | 65 |
|
63 |
| - context('when src pattern includes `base` option', function () { |
64 |
| - it('dirname is path from given directory to file', function (done) { |
| 66 | + context('when src pattern includes `base` option', function() { |
| 67 | + it('dirname is path from given directory to file', function(done) { |
65 | 68 | var srcPattern = 'test/**/*.min.txt';
|
66 |
| - var srcOptions = {base: process.cwd()}; |
67 |
| - var obj = function (path) { |
| 69 | + var srcOptions = { base: process.cwd() }; |
| 70 | + var obj = function(path) { |
68 | 71 | path.dirname.should.equal(Path.join('test', 'fixtures'));
|
69 | 72 | };
|
70 |
| - helper({pattern: srcPattern, options: srcOptions}, obj, null, done); |
| 73 | + helper({ pattern: srcPattern, options: srcOptions }, obj, null, done); |
71 | 74 | });
|
72 | 75 | });
|
73 | 76 | });
|
74 | 77 |
|
75 |
| - describe('basename', function () { |
76 |
| - it('strips extension like Path.basename(path, ext)', function (done) { |
| 78 | + describe('basename', function() { |
| 79 | + it('strips extension like Path.basename(path, ext)', function(done) { |
77 | 80 | var srcPattern = 'test/fixtures/hello.min.txt';
|
78 |
| - var obj = function (path) { |
| 81 | + var obj = function(path) { |
79 | 82 | path.basename.should.equal('hello.min');
|
80 |
| - path.basename.should.equal(Path.basename(srcPattern, Path.extname(srcPattern))); |
| 83 | + path.basename.should.equal( |
| 84 | + Path.basename(srcPattern, Path.extname(srcPattern)) |
| 85 | + ); |
81 | 86 | };
|
82 | 87 | helper(srcPattern, obj, null, done);
|
83 | 88 | });
|
84 | 89 | });
|
85 | 90 |
|
86 |
| - describe('extname', function () { |
87 |
| - it('includes \'.\' like Path.extname', function (done) { |
| 91 | + describe('extname', function() { |
| 92 | + it("includes '.' like Path.extname", function(done) { |
88 | 93 | var srcPattern = 'test/fixtures/hello.txt';
|
89 |
| - var obj = function (path) { |
| 94 | + var obj = function(path) { |
90 | 95 | path.extname.should.equal('.txt');
|
91 | 96 | path.extname.should.equal(Path.extname(srcPattern));
|
92 | 97 | };
|
93 | 98 | helper(srcPattern, obj, null, done);
|
94 | 99 | });
|
95 | 100 |
|
96 |
| - it('excludes multiple extensions like Path.extname', function (done) { |
| 101 | + it('excludes multiple extensions like Path.extname', function(done) { |
97 | 102 | var srcPattern = 'test/fixtures/hello.min.txt';
|
98 |
| - var obj = function (path) { |
| 103 | + var obj = function(path) { |
99 | 104 | path.extname.should.equal('.txt');
|
100 | 105 | path.extname.should.equal(Path.extname(srcPattern));
|
101 | 106 | };
|
102 | 107 | helper(srcPattern, obj, null, done);
|
103 | 108 | });
|
104 | 109 | });
|
105 | 110 |
|
106 |
| - describe('multiExt option', function () { |
107 |
| - it('includes multiple extensions in extname', function (done) { |
| 111 | + describe('multiExt option', function() { |
| 112 | + it('includes multiple extensions in extname', function(done) { |
108 | 113 | var srcPattern = 'test/fixtures/hello.min.txt';
|
109 |
| - var obj = function (path) { |
| 114 | + var obj = function(path) { |
110 | 115 | path.extname.should.equal('.min.txt');
|
111 | 116 | path.basename.should.equal('hello');
|
112 | 117 | };
|
113 | 118 | helper(srcPattern, obj, null, done, { multiExt: true });
|
114 | 119 | });
|
115 | 120 | });
|
116 | 121 |
|
117 |
| - describe('original file context', function () { |
118 |
| - it('passed to plugin as second argument', function (done) { |
| 122 | + describe('original file context', function() { |
| 123 | + it('passed to plugin as second argument', function(done) { |
119 | 124 | var srcPattern = 'test/fixtures/hello.min.txt';
|
120 |
| - var obj = function (path, file) { |
| 125 | + var obj = function(path, file) { |
121 | 126 | file.should.be.instanceof(Object);
|
122 | 127 | file.should.be.ok();
|
123 | 128 | };
|
124 | 129 | helper(srcPattern, obj, null, done, { multiExt: true });
|
125 | 130 | });
|
126 | 131 |
|
127 |
| - it('has expected properties', function (done) { |
| 132 | + it('has expected properties', function(done) { |
128 | 133 | var srcPattern = 'test/fixtures/hello.min.txt';
|
129 |
| - var obj = function (path, file) { |
| 134 | + var obj = function(path, file) { |
130 | 135 | file.path.should.equal(Path.resolve(srcPattern));
|
131 | 136 | file.base.should.equal(Path.dirname(Path.resolve(srcPattern)));
|
132 | 137 | file.basename.should.equal(Path.basename(srcPattern));
|
|
0 commit comments