Skip to content

Commit 74cb955

Browse files
author
Mariusz Pasinski
committed
refactor: check each path in separate tests
1 parent bb8b7b3 commit 74cb955

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

packages/host/src/node/path-utils.test.ts

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -375,29 +375,28 @@ describe("determineModuleContext", () => {
375375
});
376376

377377
describe("findNodeAddonForBindings()", () => {
378-
it("should look for addons in common paths", (context) => {
379-
// Arrange
380-
const expectedPaths = {
381-
"addon_1": "addon_1.node",
382-
"addon_2": "build/Release/addon_2.node",
383-
"addon_3": "build/Debug/addon_3.node",
384-
"addon_4": "build/addon_4.node",
385-
"addon_5": "out/Release/addon_5.node",
386-
"addon_6": "out/Debug/addon_6.node",
387-
"addon_7": "Release/addon_7.node",
388-
"addon_8": "Debug/addon_8.node",
389-
};
390-
const tempDirectoryPath = setupTempDirectory(context,
391-
Object.fromEntries(
392-
Object.values(expectedPaths)
393-
.map((p) => [p, "// This is supposed to be a binary file"])
394-
)
395-
);
396-
// Act & Assert
397-
Object.entries(expectedPaths).forEach(([name, relPath]) => {
398-
const expectedPath = path.join(tempDirectoryPath, relPath);
378+
const expectedPaths = {
379+
"addon_1": "addon_1.node",
380+
"addon_2": "build/Release/addon_2.node",
381+
"addon_3": "build/Debug/addon_3.node",
382+
"addon_4": "build/addon_4.node",
383+
"addon_5": "out/Release/addon_5.node",
384+
"addon_6": "out/Debug/addon_6.node",
385+
"addon_7": "Release/addon_7.node",
386+
"addon_8": "Debug/addon_8.node",
387+
};
388+
389+
for (let [name, relPath] of Object.entries(expectedPaths)) {
390+
it(`should look for addons in common paths (${name} in "${relPath}")`, (context) => {
391+
// Arrange
392+
const tempDirectoryPath = setupTempDirectory(context, {
393+
[relPath]: "// This is supposed to be a binary file",
394+
});
395+
// Act
399396
const actualPath = findNodeAddonForBindings(name, tempDirectoryPath);
400-
assert.equal(actualPath, expectedPath);
397+
// Assert
398+
const expectedAbsPath = path.join(tempDirectoryPath, relPath);
399+
assert.equal(actualPath, expectedAbsPath);
401400
});
402-
});
401+
}
403402
});

0 commit comments

Comments
 (0)