@@ -103,7 +103,7 @@ describe('ConcatJS', () => {
103
103
} ) ;
104
104
} ) ;
105
105
106
- it ( 'should not concat scripts which exist in some htmls (which have local scripts) ' , ( ) => {
106
+ it ( 'should concat scripts which exist in some htmls' , ( ) => {
107
107
108
108
const promise = concatJS . call ( hexo ) ;
109
109
return promise . then ( ( ) => {
@@ -119,16 +119,16 @@ describe('ConcatJS', () => {
119
119
} ) ;
120
120
// assertion
121
121
if ( file === 'concatJS1.html' ) {
122
- expect ( srcs . some ( src => src . startsWith ( '/script2.js' ) ) ) . to . be . true ;
122
+ expect ( srcs . some ( src => src . startsWith ( '/script2.js' ) ) ) . to . be . false ;
123
123
}
124
124
} else if ( file . includes ( 'script2.js' ) ) {
125
- expect ( hexoRoute . buffer [ format ( file ) ] , 'js file has been removed' ) . to . be . ok ;
125
+ expect ( hexoRoute . buffer [ format ( file ) ] , 'js file has been removed' ) . to . be . undefined ;
126
126
}
127
127
}
128
128
} ) ;
129
129
} ) ;
130
130
131
- it ( 'should concat scripts which exist in all htmls (which have local scripts) ' , ( ) => {
131
+ it ( 'should concat scripts which exist in all htmls' , ( ) => {
132
132
133
133
const promise = concatJS . call ( hexo ) ;
134
134
return promise . then ( ( ) => {
@@ -158,115 +158,115 @@ describe('ConcatJS', () => {
158
158
} ) ;
159
159
} ) ;
160
160
161
- describe ( 'when `include` option exist' , ( ) => {
162
- // Configure.
163
- let include = [ 'script2' ] ;
164
- const hexo = {
165
- config : {
166
- js_concator : {
167
- enable : true ,
168
- bundle_path : '//js/bundle.js' ,
169
- include,
170
- }
171
- } ,
172
- route : hexoRoute ,
173
- } ;
161
+ // describe('when `include` option exist', () => {
162
+ // // Configure.
163
+ // let include = ['script2'];
164
+ // const hexo = {
165
+ // config: {
166
+ // js_concator: {
167
+ // enable: true,
168
+ // bundle_path: '//js/bundle.js',
169
+ // include,
170
+ // }
171
+ // },
172
+ // route: hexoRoute,
173
+ // };
174
174
175
- beforeEach ( ( ) => {
176
- include = [ 'script2' ] ;
177
- } ) ;
175
+ // beforeEach(() => {
176
+ // include = ['script2'];
177
+ // });
178
178
179
- it ( 'should warp the `include` to an array if it is not an array' , ( ) => {
180
- include = 'script'
181
- hexo . config . js_concator . include = include ;
182
- const promise = concatJS . call ( hexo ) ;
183
- return promise . then ( ( ) => {
184
- for ( const file of fixtures ) {
185
- if ( file . includes ( '.html' ) ) {
186
- // extract src
187
- const $ = cheerio . load ( hexoRoute . buffer [ file ] ) ;
188
- const srcs = [ ] ;
189
- $ ( 'script[src]' ) . each ( ( idx , ele ) => {
190
- const $script = $ ( ele ) ;
191
- const src = $script . attr ( 'src' ) ;
192
- srcs . push ( src ) ;
193
- } ) ;
179
+ // it('should warp the `include` to an array if it is not an array', () => {
180
+ // include = 'script'
181
+ // hexo.config.js_concator.include = include;
182
+ // const promise = concatJS.call(hexo);
183
+ // return promise.then(() => {
184
+ // for (const file of fixtures) {
185
+ // if (file.includes('.html')) {
186
+ // // extract src
187
+ // const $ = cheerio.load(hexoRoute.buffer[file]);
188
+ // const srcs = [];
189
+ // $('script[src]').each((idx, ele) => {
190
+ // const $script = $(ele);
191
+ // const src = $script.attr('src');
192
+ // srcs.push(src);
193
+ // });
194
194
195
- // assertion
196
- if ( file === 'concatJS1.html' || file === 'concatJS2.html' ) {
197
- expect ( srcs ) . contains ( format ( hexo . config . js_concator . bundle_path ) ) ;
198
- } else {
199
- expect ( srcs ) . does . not . contains ( format ( hexo . config . js_concator . bundle_path ) ) ;
200
- }
201
- } else if ( file . includes ( 'script1.js' ) ||
202
- file . includes ( 'script3.js' ) ||
203
- [ include ] . some ( pattern => minimatch ( file , pattern , { matchBase : true } ) ) ) {
204
- expect ( hexoRoute . buffer [ format ( file ) ] , 'js file has been removed' ) . to . be . undefined ;
205
- }
206
- expect ( hexoRoute . buffer [ format ( hexo . config . js_concator . bundle_path ) ] ) . to . has . length . greaterThan ( 0 ) ;
207
- }
208
- } ) ;
209
- } ) ;
195
+ // // assertion
196
+ // if (file === 'concatJS1.html' || file === 'concatJS2.html') {
197
+ // expect(srcs).contains(format(hexo.config.js_concator.bundle_path));
198
+ // } else {
199
+ // expect(srcs).does.not.contains(format(hexo.config.js_concator.bundle_path));
200
+ // }
201
+ // } else if (file.includes('script1.js') ||
202
+ // file.includes('script3.js') ||
203
+ // [include].some(pattern => minimatch(file, pattern, { matchBase: true }))) {
204
+ // expect(hexoRoute.buffer[format(file)], 'js file has been removed').to.be.undefined;
205
+ // }
206
+ // expect(hexoRoute.buffer[format(hexo.config.js_concator.bundle_path)]).to.has.length.greaterThan(0);
207
+ // }
208
+ // });
209
+ // });
210
210
211
- it ( 'should not touch the remote scripts' , ( ) => {
211
+ // it('should not touch the remote scripts', () => {
212
212
213
- const promise = concatJS . call ( hexo ) ;
214
- return promise . then ( ( ) => {
215
- for ( const file of fixtures ) {
216
- if ( file . includes ( '.html' ) ) {
217
- const $raw = cheerio . load ( htmls [ file ] ) ;
218
- const expectRemoteScripts = [ ] ;
219
- $raw ( 'script[src]' ) . each ( ( idx , ele ) => {
220
- const $script = $raw ( ele ) ;
221
- const src = $script . attr ( 'src' ) ;
222
- if ( src . startsWith ( '//' ) || src . startsWith ( 'http' ) ) {
223
- expectRemoteScripts . push ( src ) ;
224
- }
225
- } ) ;
213
+ // const promise = concatJS.call(hexo);
214
+ // return promise.then(() => {
215
+ // for (const file of fixtures) {
216
+ // if (file.includes('.html')) {
217
+ // const $raw = cheerio.load(htmls[file]);
218
+ // const expectRemoteScripts = [];
219
+ // $raw('script[src]').each((idx, ele) => {
220
+ // const $script = $raw(ele);
221
+ // const src = $script.attr('src');
222
+ // if (src.startsWith('//') || src.startsWith('http')) {
223
+ // expectRemoteScripts.push(src);
224
+ // }
225
+ // });
226
226
227
- const $ = cheerio . load ( hexoRoute . buffer [ file ] ) ;
228
- const actualRemoteScripts = [ ] ;
229
- $ ( 'script[src]' ) . each ( ( idx , ele ) => {
230
- const $script = $ ( ele ) ;
231
- const src = $script . attr ( 'src' ) ;
232
- if ( src . startsWith ( '//' ) || src . startsWith ( 'http' ) ) {
233
- actualRemoteScripts . push ( src ) ;
234
- }
235
- } ) ;
236
- expect ( actualRemoteScripts ) . to . be . deep . equal ( expectRemoteScripts ) ;
237
- }
238
- }
239
- } ) ;
240
- } ) ;
227
+ // const $ = cheerio.load(hexoRoute.buffer[file]);
228
+ // const actualRemoteScripts = [];
229
+ // $('script[src]').each((idx, ele) => {
230
+ // const $script = $(ele);
231
+ // const src = $script.attr('src');
232
+ // if (src.startsWith('//') || src.startsWith('http')) {
233
+ // actualRemoteScripts.push(src);
234
+ // }
235
+ // });
236
+ // expect(actualRemoteScripts).to.be.deep.equal(expectRemoteScripts);
237
+ // }
238
+ // }
239
+ // });
240
+ // });
241
241
242
- it ( 'should concat scripts which exist in all htmls (which have local scripts) or match the `include pattern`' , ( ) => {
243
- const promise = concatJS . call ( hexo ) ;
244
- return promise . then ( ( ) => {
245
- for ( const file of fixtures ) {
246
- if ( file . includes ( '.html' ) ) {
247
- // extract src
248
- const $ = cheerio . load ( hexoRoute . buffer [ file ] ) ;
249
- const srcs = [ ] ;
250
- $ ( 'script[src]' ) . each ( ( idx , ele ) => {
251
- const $script = $ ( ele ) ;
252
- const src = $script . attr ( 'src' ) ;
253
- srcs . push ( src ) ;
254
- } ) ;
242
+ // it('should concat scripts which exist in all htmls (which have local scripts) or match the `include pattern`', () => {
243
+ // const promise = concatJS.call(hexo);
244
+ // return promise.then(() => {
245
+ // for (const file of fixtures) {
246
+ // if (file.includes('.html')) {
247
+ // // extract src
248
+ // const $ = cheerio.load(hexoRoute.buffer[file]);
249
+ // const srcs = [];
250
+ // $('script[src]').each((idx, ele) => {
251
+ // const $script = $(ele);
252
+ // const src = $script.attr('src');
253
+ // srcs.push(src);
254
+ // });
255
255
256
- // assertion
257
- if ( file === 'concatJS1.html' || file === 'concatJS2.html' ) {
258
- expect ( srcs ) . contains ( format ( hexo . config . js_concator . bundle_path ) ) ;
259
- } else {
260
- expect ( srcs ) . does . not . contains ( format ( hexo . config . js_concator . bundle_path ) ) ;
261
- }
262
- } else if ( file . includes ( 'script1.js' ) ||
263
- file . includes ( 'script3.js' ) ||
264
- include . some ( pattern => minimatch ( file , pattern , { matchBase : true } ) ) ) {
265
- expect ( hexoRoute . buffer [ format ( file ) ] , 'js file has been removed' ) . to . be . undefined ;
266
- }
267
- expect ( hexoRoute . buffer [ format ( hexo . config . js_concator . bundle_path ) ] ) . to . has . length . greaterThan ( 0 ) ;
268
- }
269
- } ) ;
270
- } ) ;
271
- } ) ;
256
+ // // assertion
257
+ // if (file === 'concatJS1.html' || file === 'concatJS2.html') {
258
+ // expect(srcs).contains(format(hexo.config.js_concator.bundle_path));
259
+ // } else {
260
+ // expect(srcs).does.not.contains(format(hexo.config.js_concator.bundle_path));
261
+ // }
262
+ // } else if (file.includes('script1.js') ||
263
+ // file.includes('script3.js') ||
264
+ // include.some(pattern => minimatch(file, pattern, { matchBase: true }))) {
265
+ // expect(hexoRoute.buffer[format(file)], 'js file has been removed').to.be.undefined;
266
+ // }
267
+ // expect(hexoRoute.buffer[format(hexo.config.js_concator.bundle_path)]).to.has.length.greaterThan(0);
268
+ // }
269
+ // });
270
+ // });
271
+ // });
272
272
} ) ;
0 commit comments