Skip to content

Commit

Permalink
fix(test): Fix POSIX and file URL path resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuki31 committed May 21, 2024
1 parent b0e025c commit c4349f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions test/lsfnd.spec.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { ls, lsFiles, lsDirs } = require('..');
const { it, rejects, doesNotReject, deepEq } = require('./lib/simpletest');

const rootDir = path.resolve('..');
const rootDirPosix = path.posix.resolve('..');
const rootDirPosix = rootDir.replaceAll(path.sep, '/');

console.log(`\n\x1b[1m${path.basename(__filename)}:\x1b[0m`);

Expand Down Expand Up @@ -38,7 +38,7 @@ it('list root directory using URL object', async () => {
}, false);

it('list root directory using file URL path', async () => {
await doesNotReject(ls('file:'.concat(rootDirPosix)), URIError);
await doesNotReject(ls(pathToFileURL(rootDirPosix)), URIError);
}, false);

it('test if the options argument allows explicit null value', async () => {
Expand All @@ -63,7 +63,7 @@ it('throws an error if the given directory path not exist', async () => {
}, false);

it('throws a `URIError` if the given file URL path using unsupported protocol',
async () => await rejects(ls('http:'.concat(rootDirPosix)), URIError),
async () => await rejects(ls('http:///'.concat(rootDirPosix)), URIError),
false
);

Expand Down
6 changes: 3 additions & 3 deletions test/lsfnd.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const { it, rejects, doesNotReject, deepEq } = test; // Resolve import from Com
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const rootDir = path.resolve('..');
const rootDirPosix = path.posix.resolve('..');
const rootDirPosix = rootDir.replaceAll(path.sep, '/');

console.log(`\n\x1b[1m${path.basename(__filename)}:\x1b[0m`);

Expand Down Expand Up @@ -42,7 +42,7 @@ it('list root directory using URL object', async () => {
}, false);

it('list root directory using file URL path', async () => {
await doesNotReject(ls('file:'.concat(rootDirPosix)), URIError);
await doesNotReject(ls(pathToFileURL(rootDirPosix)), URIError);
}, false);

it('test if the options argument allows explicit null value', async () => {
Expand All @@ -67,7 +67,7 @@ it('throws an error if the given directory path not exist', async () => {
}, false);

it('throws an URIError if the given file URL path using unsupported protocol',
async () => await rejects(ls('http:'.concat(rootDirPosix)), URIError),
async () => await rejects(ls('http:///'.concat(rootDirPosix)), URIError),
false
);

Expand Down

0 comments on commit c4349f0

Please sign in to comment.