|
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 | 55 | context.skip( |
56 | 56 | 'when src pattern matches a directory with {#..#}', |
57 | | - function() { |
| 57 | + function () { |
58 | 58 | dirnameHelper('test/fixtures{0..9}/*.min.txt'); |
59 | | - } |
| 59 | + }, |
60 | 60 | ); |
61 | 61 |
|
62 | | - context('when src pattern matches a directory with an extglob', function() { |
63 | | - dirnameHelper('test/f+(ri|ixtur)es/*.min.txt'); |
64 | | - }); |
| 62 | + context( |
| 63 | + 'when src pattern matches a directory with an extglob', |
| 64 | + function () { |
| 65 | + dirnameHelper('test/f+(ri|ixtur)es/*.min.txt'); |
| 66 | + }, |
| 67 | + ); |
65 | 68 |
|
66 | | - context('when src pattern includes `base` option', function() { |
67 | | - it('dirname is path from given directory to file', function(done) { |
| 69 | + context('when src pattern includes `base` option', function () { |
| 70 | + it('dirname is path from given directory to file', function (done) { |
68 | 71 | var srcPattern = 'test/**/*.min.txt'; |
69 | 72 | var srcOptions = { base: process.cwd() }; |
70 | | - var obj = function(path) { |
| 73 | + var obj = function (path) { |
71 | 74 | path.dirname.should.equal(Path.join('test', 'fixtures')); |
72 | 75 | }; |
73 | 76 | helper({ pattern: srcPattern, options: srcOptions }, obj, null, done); |
74 | 77 | }); |
75 | 78 | }); |
76 | 79 | }); |
77 | 80 |
|
78 | | - describe('basename', function() { |
79 | | - it('strips extension like Path.basename(path, ext)', function(done) { |
| 81 | + describe('basename', function () { |
| 82 | + it('strips extension like Path.basename(path, ext)', function (done) { |
80 | 83 | var srcPattern = 'test/fixtures/hello.min.txt'; |
81 | | - var obj = function(path) { |
| 84 | + var obj = function (path) { |
82 | 85 | path.basename.should.equal('hello.min'); |
83 | 86 | path.basename.should.equal( |
84 | | - Path.basename(srcPattern, Path.extname(srcPattern)) |
| 87 | + Path.basename(srcPattern, Path.extname(srcPattern)), |
85 | 88 | ); |
86 | 89 | }; |
87 | 90 | helper(srcPattern, obj, null, done); |
88 | 91 | }); |
89 | 92 | }); |
90 | 93 |
|
91 | | - describe('extname', function() { |
92 | | - it("includes '.' like Path.extname", function(done) { |
| 94 | + describe('extname', function () { |
| 95 | + it("includes '.' like Path.extname", function (done) { |
93 | 96 | var srcPattern = 'test/fixtures/hello.txt'; |
94 | | - var obj = function(path) { |
| 97 | + var obj = function (path) { |
95 | 98 | path.extname.should.equal('.txt'); |
96 | 99 | path.extname.should.equal(Path.extname(srcPattern)); |
97 | 100 | }; |
98 | 101 | helper(srcPattern, obj, null, done); |
99 | 102 | }); |
100 | 103 |
|
101 | | - it('excludes multiple extensions like Path.extname', function(done) { |
| 104 | + it('excludes multiple extensions like Path.extname', function (done) { |
102 | 105 | var srcPattern = 'test/fixtures/hello.min.txt'; |
103 | | - var obj = function(path) { |
| 106 | + var obj = function (path) { |
104 | 107 | path.extname.should.equal('.txt'); |
105 | 108 | path.extname.should.equal(Path.extname(srcPattern)); |
106 | 109 | }; |
107 | 110 | helper(srcPattern, obj, null, done); |
108 | 111 | }); |
109 | 112 | }); |
110 | 113 |
|
111 | | - describe('multiExt option', function() { |
112 | | - it('includes multiple extensions in extname', function(done) { |
| 114 | + describe('multiExt option', function () { |
| 115 | + it('includes multiple extensions in extname', function (done) { |
113 | 116 | var srcPattern = 'test/fixtures/hello.min.txt'; |
114 | | - var obj = function(path) { |
| 117 | + var obj = function (path) { |
115 | 118 | path.extname.should.equal('.min.txt'); |
116 | 119 | path.basename.should.equal('hello'); |
117 | 120 | }; |
118 | 121 | helper(srcPattern, obj, null, done, { multiExt: true }); |
119 | 122 | }); |
120 | 123 | }); |
121 | 124 |
|
122 | | - describe('original file context', function() { |
123 | | - it('passed to plugin as second argument', function(done) { |
| 125 | + describe('original file context', function () { |
| 126 | + it('passed to plugin as second argument', function (done) { |
124 | 127 | var srcPattern = 'test/fixtures/hello.min.txt'; |
125 | | - var obj = function(path, file) { |
| 128 | + var obj = function (path, file) { |
126 | 129 | file.should.be.instanceof(Object); |
127 | 130 | file.should.be.ok(); |
128 | 131 | }; |
129 | 132 | helper(srcPattern, obj, null, done, { multiExt: true }); |
130 | 133 | }); |
131 | 134 |
|
132 | | - it('has expected properties', function(done) { |
| 135 | + it('has expected properties', function (done) { |
133 | 136 | var srcPattern = 'test/fixtures/hello.min.txt'; |
134 | | - var obj = function(path, file) { |
| 137 | + var obj = function (path, file) { |
135 | 138 | file.path.should.equal(Path.resolve(srcPattern)); |
136 | 139 | file.base.should.equal(Path.dirname(Path.resolve(srcPattern))); |
137 | 140 | file.basename.should.equal(Path.basename(srcPattern)); |
|
0 commit comments