Skip to content

Commit

Permalink
test: use fixtures.fileURL when appropriate
Browse files Browse the repository at this point in the history
PR-URL: nodejs#48990
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
aduh95 authored and rluvaton committed Aug 15, 2023
1 parent dd1f1f4 commit 21f094a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
12 changes: 1 addition & 11 deletions test/parallel/test-fs-whatwg-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,9 @@
const common = require('../common');
const fixtures = require('../common/fixtures');
const assert = require('assert');
const path = require('path');
const fs = require('fs');

function pathToFileURL(p) {
if (!path.isAbsolute(p))
throw new Error('Path must be absolute');
if (common.isWindows && p.startsWith('\\\\'))
p = p.slice(2);
return new URL(`file://${p}`);
}

const p = path.resolve(fixtures.fixturesDir, 'a.js');
const url = pathToFileURL(p);
const url = fixtures.fileURL('a.js');

assert(url instanceof URL);

Expand Down
5 changes: 2 additions & 3 deletions test/parallel/test-module-create-require.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
'use strict';

require('../common');
const fixtures = require('../common/fixtures');
const assert = require('assert');
const path = require('path');

const { createRequire } = require('module');

const p = path.resolve(__dirname, '..', 'fixtures', 'fake.js');
const u = new URL(`file://${p}`);
const u = fixtures.fileURL('fake.js');

const reqToo = createRequire(u);
assert.deepStrictEqual(reqToo('./experimental'), { ofLife: 42 });
Expand Down

0 comments on commit 21f094a

Please sign in to comment.