Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] LocatorResourcePool wait for resources in prepare step #719

Merged
merged 2 commits into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/lbt/resources/LocatorResourcePool.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class LocatorResourcePool extends ResourcePool {
if (!moduleName) {
moduleName = resource.getPath().slice("/resources/".length);
}
this.addResource(new LocatorResource(this, resource, moduleName));
return this.addResource(new LocatorResource(this, resource, moduleName));
}).filter(Boolean)
);
}
Expand Down
16 changes: 16 additions & 0 deletions test/lib/lbt/resources/LocatorResourcePool.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
const test = require("ava");
const LocatorResourcePool = require("../../../../lib/lbt/resources/LocatorResourcePool");
const Resource = require("@ui5/fs").Resource;

test("getIgnoreMissingModules", async (t) => {
const resourcePool = new LocatorResourcePool({ignoreMissingModules: true});
t.true(resourcePool.getIgnoreMissingModules(), "ignoreMissingModules is true");
});

test("wait for resources to finish prepare", async (t) => {
let promiseResolved = false;
const promise = new Promise((resolve) => {
setTimeout(() => {
promiseResolved = true;
resolve();
}, 10);
});
const resourcePool = new LocatorResourcePool();
resourcePool.addResource = () => promise;
return resourcePool.prepare([new Resource({path: "mypath"})]).then(() => {
t.true(promiseResolved, "addResources promise is resolved before prepare promise is resolved");
});
});