Skip to content

Commit f96c978

Browse files
committed
add test case
1 parent 87cd366 commit f96c978

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

test/index.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,66 @@ describe('fis3-packager-smart pack', function() {
152152
});
153153
});
154154
});
155+
156+
157+
// 所有js打包成一个文件
158+
describe('fis3-packager-smart pack - jsAllInOne', function() {
159+
160+
var dist = path.join(__dirname, 'allInOne');
161+
beforeEach(function() {
162+
163+
164+
_.del(dist);
165+
166+
_self.options = {
167+
autoPack: true,
168+
cssInline: true,
169+
jsAllInOne: true
170+
};
171+
172+
fis.match('::package', {
173+
packager: _self
174+
});
175+
176+
fis.match('*', {
177+
deploy: fis.plugin('local-deliver', {
178+
to: dist
179+
})
180+
});
181+
182+
fis.hook('commonjs');
183+
184+
185+
fis.match(/^\/modules\/(.+)\.js$/, {
186+
isMod: true,
187+
id: '$1'
188+
})
189+
.match(/^\/modules\/((?:[^\/]+\/)*)([^\/]+)\/\2\.(js)$/i, {
190+
// isMod: true,
191+
id: '$1$2'
192+
})
193+
.match(/^\/lego_modules\/(.+)\.js$/i, {
194+
isMod: true,
195+
id: '$1'
196+
});
197+
198+
fis.match(/^\/(pages\/.+)\.js$/, {
199+
isMod: true,
200+
id: '$1'
201+
});
202+
203+
});
204+
205+
it('lego hook', function(done) {
206+
207+
release({
208+
unique: true
209+
}, function() {
210+
expect(fs.existsSync(path.join(dist, 'pkg/index.html_aio.js'))).to.be.true;
211+
var content = fs.readFileSync(path.join(dist, 'index.html'));
212+
expect(/<script\ssrc=\"\/pkg\/index\.html_aio\.js\"><\/script>/.test(content)).to.be.true;
213+
done();
214+
fis.log.info('release complete');
215+
});
216+
});
217+
});

0 commit comments

Comments
 (0)