Skip to content

Commit 09003dd

Browse files
committed
a test of import and a fix for windows
1 parent a239975 commit 09003dd

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

test/module-hooks/test-module-hooks-load-url-change-import.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { mustCall } from '../common/index.mjs';
44
import assert from 'node:assert';
55
import { registerHooks } from 'node:module';
66
import { fileURL } from '../common/fixtures.mjs';
7+
import { pathToFileURL } from "node:url";
8+
import { sep as pathSep } from "node:path";
79

810
// This tests shows the url parameter in `load` can be changed in the `nextLoad` call
911
// It changes `foo` package name into `redirected-fs` and then loads `redirected-fs`
@@ -12,12 +14,12 @@ const hook = registerHooks({
1214
resolve(specifier, context, nextResolve) {
1315
assert.strictEqual(specifier, 'foo');
1416
return {
15-
url: 'file:///foo',
17+
url: 'foo://bar',
1618
shortCircuit: true,
1719
};
1820
},
1921
load: mustCall(function load(url, context, nextLoad) {
20-
assert.strictEqual(url, 'file:///foo');
22+
assert.strictEqual(url, 'foo://bar');
2123
return nextLoad(
2224
fileURL('module-hooks', `redirected-fs.js`).href,
2325
context

test/module-hooks/test-module-hooks-load-url-change-require.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ const hook = registerHooks({
1212
resolve(specifier, context, nextResolve) {
1313
assert.strictEqual(specifier, 'foo');
1414
return {
15-
url: 'file:///foo',
15+
url: "foo://bar",
1616
shortCircuit: true,
1717
};
1818
},
1919
load: common.mustCall(function load(url, context, nextLoad) {
20-
assert.strictEqual(url, 'file:///foo');
20+
assert.strictEqual(url, "foo://bar",);
2121
return nextLoad(
2222
fixtures.fileURL('module-hooks', `redirected-fs.js`).href,
2323
context,

0 commit comments

Comments
 (0)