Skip to content

Commit

Permalink
fixup! fixup! fs: pass correct path to DirentFromStats during glob
Browse files Browse the repository at this point in the history
  • Loading branch information
avivkeller committed Sep 25, 2024
1 parent 03259b8 commit a04da46
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions test/parallel/test-fs-glob.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ describe('fsPromises glob', function() {
}
});

const normalizeDirent = (dirent) => relative(fixtureDir, join(dirent.parentPath, dirent.name));
const normalizePath = (path) => (isAbsolute(path) ? relative(fixtureDir, path) : join(path));

describe('glob - withFileTypes', function() {
const promisified = promisify(glob);
for (const [pattern, expected] of Object.entries(patterns)) {
Expand All @@ -348,10 +351,7 @@ describe('glob - withFileTypes', function() {
exclude: (dirent) => assert.ok(dirent instanceof Dirent),
});
assertDirents(actual);
assert.deepStrictEqual(
actual.map((dirent) => relative(fixtureDir, join(dirent.parentPath, dirent.name))).sort(),
expected.map((path) => (isAbsolute(path) ? relative(fixtureDir, path) : path)).sort()
);
assert.deepStrictEqual(actual.map(normalizeDirent).sort(), expected.map(normalizePath).sort());
});
}
});
Expand All @@ -365,10 +365,7 @@ describe('globSync - withFileTypes', function() {
exclude: (dirent) => assert.ok(dirent instanceof Dirent),
});
assertDirents(actual);
assert.deepStrictEqual(
actual.map((dirent) => relative(fixtureDir, join(dirent.parentPath, dirent.name))).sort(),
expected.map((path) => (isAbsolute(path) ? relative(fixtureDir, path) : path)).sort()
);
assert.deepStrictEqual(actual.map(normalizeDirent).sort(), expected.map(normalizePath).sort());
});
}
});
Expand All @@ -383,10 +380,7 @@ describe('fsPromises glob - withFileTypes', function() {
exclude: (dirent) => assert.ok(dirent instanceof Dirent),
})) actual.push(item);
assertDirents(actual);
assert.deepStrictEqual(
actual.map((dirent) => relative(fixtureDir, join(dirent.parentPath, dirent.name))).sort(),
expected.map((path) => (isAbsolute(path) ? relative(fixtureDir, path) : path)).sort()
);
assert.deepStrictEqual(actual.map(normalizeDirent).sort(), expected.map(normalizePath).sort());
});
}
});

0 comments on commit a04da46

Please sign in to comment.