From 8934088b780d9c9de688101adb2a2125ccc94cbb Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Mon, 6 Dec 2021 14:22:40 +0100 Subject: [PATCH] Fixes and update tests --- lib/lbt/resources/ResourceCollector.js | 6 +++--- test/lib/lbt/resources/ResourceCollector.js | 17 +++++++---------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/lbt/resources/ResourceCollector.js b/lib/lbt/resources/ResourceCollector.js index b962ca9e7..a715f28cb 100644 --- a/lib/lbt/resources/ResourceCollector.js +++ b/lib/lbt/resources/ResourceCollector.js @@ -288,9 +288,9 @@ class ResourceCollector { // FIXME: "merged" property is only calculated in ResourceInfo#copyFrom // Therefore using the same logic here to compute it. - if (nonDbgInfo.included != null && nonDbgInfo.included.size > 0) { - // We need to analyze the dbg resource if the non-dbg variant is a bundle - // because we will (usually) have different content. + if (!nonDbgInfo || (nonDbgInfo.included != null && nonDbgInfo.included.size > 0)) { + // We need to analyze the dbg resource if there is no non-dbg variant or + // it is a bundle because we will (usually) have different content. debugBundlePromises.push( this.enrichWithDependencyInfo(dbgInfo) ); diff --git a/test/lib/lbt/resources/ResourceCollector.js b/test/lib/lbt/resources/ResourceCollector.js index 102377612..9f80905f5 100644 --- a/test/lib/lbt/resources/ResourceCollector.js +++ b/test/lib/lbt/resources/ResourceCollector.js @@ -95,7 +95,7 @@ test.serial("visitResource: ensure proper matching of indicator files", async (t t.is(resourceCollector.components.size, 0, "No prefixes should be added"); }); -test.serial("groupResourcesByComponents: debugBundles", async (t) => { +test.serial("groupResourcesByComponents: external resources", async (t) => { const resourceCollector = new ResourceCollector(); resourceCollector.setExternalResources({ "testcomp": ["my/file.js"] @@ -155,9 +155,7 @@ test.serial("determineResourceDetails: Debug bundle", async (t) => { const enrichWithDependencyInfoStub = sinon.stub(resourceCollector, "enrichWithDependencyInfo").resolves(); await resourceCollector.visitResource({getPath: () => "/resources/MyBundle-dbg.js", getSize: async () => 13}); - await resourceCollector.determineResourceDetails({ - debugBundles: ["MyBundle-dbg.js"] - }); + await resourceCollector.determineResourceDetails({}); t.is(enrichWithDependencyInfoStub.callCount, 1, "enrichWithDependencyInfo is called once"); t.is(enrichWithDependencyInfoStub.getCall(0).args[0].name, "MyBundle-dbg.js", "enrichWithDependencyInfo is called with debug bundle"); @@ -183,16 +181,15 @@ test.serial("determineResourceDetails: Debug files and non-debug files", async ( })); await resourceCollector.determineResourceDetails({ - debugResources: ["**/*-dbg.js"], - debugBundles: ["MyBundle-dbg.js"] + debugResources: ["**/*-dbg.js"] }); t.is(enrichWithDependencyInfoStub.callCount, 3, "enrichWithDependencyInfo is called three times"); - t.is(enrichWithDependencyInfoStub.getCall(0).args[0].name, "MyBundle-dbg.js", - "enrichWithDependencyInfo called with debug bundle"); - t.is(enrichWithDependencyInfoStub.getCall(1).args[0].name, "mylib/MyControlA.js", + t.is(enrichWithDependencyInfoStub.getCall(0).args[0].name, "mylib/MyControlA.js", "enrichWithDependencyInfo called with non-debug control A"); - t.is(enrichWithDependencyInfoStub.getCall(2).args[0].name, "mylib/MyControlB.js", + t.is(enrichWithDependencyInfoStub.getCall(1).args[0].name, "mylib/MyControlB.js", "enrichWithDependencyInfo called with non-debug control B"); + t.is(enrichWithDependencyInfoStub.getCall(2).args[0].name, "MyBundle-dbg.js", + "enrichWithDependencyInfo called with debug bundle"); t.is(resourceCollector._resources.get("MyBundle-dbg.js").isDebug, true, "MyBundle-dbg is a debug file"); t.is(resourceCollector._resources.get("MyBundle-dbg.js").dynRequired, true,