Skip to content

Commit 7ec38a4

Browse files
committed
[INTERNAL] ResourceCollector: Fix existing tests
1 parent b9d397e commit 7ec38a4

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

test/lib/lbt/resources/ResourceCollector.js

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

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

@@ -111,7 +111,7 @@ test.serial("determineResourceDetails: properties", async (t) => {
111111
getPath: () => "/resources/mylib/i18n/i18n.properties", getSize: async () => 13
112112
});
113113
await resourceCollector.determineResourceDetails({});
114-
resourceCollector.groupResourcesByComponents({});
114+
resourceCollector.groupResourcesByComponents();
115115
const resources = resourceCollector.components.get("mylib/").resources;
116116
t.deepEqual(resources.map((res) => res.i18nName),
117117
[null, "i18n/i18n.properties", "i18n/i18n.properties"], "i18nName was set");

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)