Skip to content

Commit 29f4fc4

Browse files
author
emilien.escalle
committed
Improve code coverage
1 parent 1bb32c7 commit 29f4fc4

File tree

2 files changed

+17
-35
lines changed

2 files changed

+17
-35
lines changed

lib/packExternalModules.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -153,28 +153,28 @@ function findExternalOrigin(issuer) {
153153
}
154154

155155
function getExternalModules(stats) {
156-
if (!stats.compilation.chunks) {
157-
return [];
158-
}
159-
160-
const externals = new Set();
161-
for (const chunk of stats.compilation.chunks) {
162-
if (!chunk.modulesIterable) {
163-
continue;
164-
}
156+
if (stats.compilation.chunks) {
157+
const externals = new Set();
158+
for (const chunk of stats.compilation.chunks) {
159+
if (!chunk.modulesIterable) {
160+
continue;
161+
}
165162

166-
// Explore each module within the chunk (built inputs):
167-
for (const module of chunk.modulesIterable) {
168-
if (isExternalModule(module)) {
169-
externals.add({
170-
origin: _.get(findExternalOrigin(module.issuer), 'rawRequest'),
171-
external: getExternalModuleName(module)
172-
});
163+
// Explore each module within the chunk (built inputs):
164+
for (const module of chunk.modulesIterable) {
165+
if (isExternalModule(module)) {
166+
externals.add({
167+
origin: _.get(findExternalOrigin(module.issuer), 'rawRequest'),
168+
external: getExternalModuleName(module)
169+
});
170+
}
173171
}
174172
}
173+
174+
return Array.from(externals);
175175
}
176176

177-
return Array.from(externals);
177+
return [];
178178
}
179179

180180
module.exports = {

tests/packExternalModules.test.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -332,24 +332,6 @@ describe('packExternalModules', () => {
332332
]));
333333
});
334334

335-
it('should do nothing if webpackIncludeModules is empty', () => {
336-
module.configuration = new Configuration();
337-
module.compileStats = {
338-
stats: {
339-
compilation: {
340-
chunks: []
341-
}
342-
}
343-
};
344-
345-
return expect(module.packExternalModules()).to.be.fulfilled
346-
.then(() => BbPromise.all([
347-
expect(fsExtraMock.copy).to.not.have.been.called,
348-
expect(packagerFactoryMock.get).to.not.have.been.called,
349-
expect(writeFileSyncStub).to.not.have.been.called,
350-
]));
351-
});
352-
353335
it('should copy needed package sections if available', () => {
354336
const originalPackageJSON = {
355337
name: 'test-service',

0 commit comments

Comments
 (0)