Skip to content

Commit

Permalink
[FIX] LocatorResourcePool: Wait for resources in prepare step (#719)
Browse files Browse the repository at this point in the history
Issue was introduced with #695.
  • Loading branch information
flovogt authored Mar 9, 2022
1 parent 9955a0c commit 1b7f93f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
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");
});
});

0 comments on commit 1b7f93f

Please sign in to comment.