Skip to content

Commit 245b592

Browse files
committed
[INTERNAL] ResourceCollector: Fix existing tests
1 parent 90cd9d0 commit 245b592

File tree

2 files changed

+13
-23
lines changed

2 files changed

+13
-23
lines changed

test/lib/lbt/resources/ResourceCollector.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ test.serial("groupResourcesByComponents: debugBundles", async (t) => {
7777
});
7878
await resourceCollector.visitResource({getPath: () => "/resources/testcomp/Component.js", getSize: async () => 13});
7979
await resourceCollector.visitResource({getPath: () => "/resources/my/file.js", getSize: async () => 13});
80-
resourceCollector.groupResourcesByComponents({debugBundles: [".*-dbg.js"]});
80+
resourceCollector.groupResourcesByComponents();
8181
t.is(resourceCollector.resources.size, 0, "all resources were deleted");
8282
});
8383

@@ -86,7 +86,7 @@ test.serial("groupResourcesByComponents: theme", async (t) => {
8686
await resourceCollector.visitResource({getPath: () => "/resources/themes/a/.theming", getSize: async () => 13});
8787
t.is(resourceCollector.themePackages.size, 1, "1 theme was added");
8888
await resourceCollector.determineResourceDetails({});
89-
resourceCollector.groupResourcesByComponents({});
89+
resourceCollector.groupResourcesByComponents();
9090
t.is(resourceCollector.themePackages.get("themes/a/").resources.length, 1, "1 theme was grouped");
9191
});
9292

@@ -102,7 +102,7 @@ test.serial("determineResourceDetails: properties", async (t) => {
102102
await resourceCollector.visitResource({getPath: () => "/resources/mylib/i18n/i18n_de.properties", getSize: async () => 13});
103103
await resourceCollector.visitResource({getPath: () => "/resources/mylib/i18n/i18n.properties", getSize: async () => 13});
104104
await resourceCollector.determineResourceDetails({});
105-
resourceCollector.groupResourcesByComponents({});
105+
resourceCollector.groupResourcesByComponents();
106106
const resources = resourceCollector.components.get("mylib/").resources;
107107
t.deepEqual(resources.map((res) => res.i18nName), [null, "i18n/i18n.properties", "i18n/i18n.properties"], "i18nName was set");
108108
});
@@ -119,7 +119,7 @@ test.serial("determineResourceDetails: view.xml", async (t) => {
119119
await resourceCollector.visitResource({getPath: () => "/resources/mylib/my.view.xml", getSize: async () => 13});
120120
await resourceCollector.determineResourceDetails({});
121121
t.is(enrichWithDependencyInfoStub.callCount, 1, "is called once");
122-
t.is(enrichWithDependencyInfoStub.getCall(0).args[0].name, "mylib/my.view.xml", "is called with view");
122+
t.is(enrichWithDependencyInfoStub.getCall(0).args[0].resourceInfo.name, "mylib/my.view.xml", "is called with view");
123123
});
124124

125125
test.serial("enrichWithDependencyInfo: add infos to resourceinfo", async (t) => {
@@ -147,7 +147,7 @@ test.serial("enrichWithDependencyInfo: add infos to resourceinfo", async (t) =>
147147
}
148148
});
149149
const resourceInfo = {};
150-
await resourceCollector.enrichWithDependencyInfo(resourceInfo);
150+
await resourceCollector.enrichWithDependencyInfo({resourceInfo});
151151
t.deepEqual(resourceInfo, {
152152
condRequired: new Set(["mydependency.conditional"]),
153153
dynRequired: true,

test/lib/lbt/resources/ResourceInfoList.js

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,28 @@ test("add: add new resources", (t) => {
1616
t.falsy(result.module, "module is not set");
1717
});
1818

19-
test("add: add source then debug resources", (t) => {
19+
test("add: add non-debug resource", (t) => {
2020
const resourceInfoList = new ResourceInfoList("prefix");
2121

22-
resourceInfoList.add({name: "myfile.js", module: "myfile.js", size: 13});
22+
resourceInfoList.add({name: "myfile.js", module: "myfile.js", size: 13, required: new Set(["some-dep.js"])});
2323

24-
const myInfo = {name: "myfile-dbg.js", size: 13};
25-
resourceInfoList.add(myInfo);
26-
27-
t.is(resourceInfoList.resources.length, 2, "two entries");
24+
t.is(resourceInfoList.resources.length, 1, "one resource added");
2825

2926
const result = resourceInfoList.resourcesByName.get("../myfile.js");
3027
t.is(result.module, "myfile.js", "module is set");
31-
32-
const resultDbg = resourceInfoList.resourcesByName.get("../myfile-dbg.js");
33-
t.is(resultDbg.module, "myfile.js", "module is set");
28+
t.deepEqual(result.required, new Set(["some-dep.js"]), "module is set");
3429
});
3530

36-
test("add: add debug then source resources", (t) => {
31+
test("add: add debug resources", (t) => {
3732
const resourceInfoList = new ResourceInfoList("prefix");
3833

39-
resourceInfoList.add({name: "myfile-dbg.js", size: 13});
34+
resourceInfoList.add({name: "myfile-dbg.js", size: 13, required: new Set(["some-dep.js"])});
4035

41-
const myInfo = {name: "myfile.js", module: "myfile.js", size: 13};
42-
resourceInfoList.add(myInfo);
43-
44-
t.is(resourceInfoList.resources.length, 2, "two entries");
45-
46-
const result = resourceInfoList.resourcesByName.get("../myfile.js");
47-
t.is(result.module, "myfile.js", "module is set");
36+
t.is(resourceInfoList.resources.length, 1, "one resource added");
4837

4938
const resultDbg = resourceInfoList.resourcesByName.get("../myfile-dbg.js");
5039
t.is(resultDbg.module, "myfile.js", "module is set");
40+
t.deepEqual(resultDbg.required, new Set(["some-dep.js"]), "module is set");
5141
});
5242

5343
test("add: add i18n resource", (t) => {

0 commit comments

Comments
 (0)