Skip to content

Commit bc0f582

Browse files
committed
test(lib): refactor
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent 702dfdc commit bc0f582

File tree

9 files changed

+22
-25
lines changed

9 files changed

+22
-25
lines changed

src/lib/__tests__/add-ext.spec.mts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55

66
import testSubject from '#lib/add-ext'
77
import formatExt from '#lib/format-ext'
8-
import pathToFileURL from '#lib/path-to-file-url'
98

109
describe('unit:lib/addExt', () => {
1110
it.each<[URL, string | null | undefined]>([
12-
[pathToFileURL('dist/lib/add-ext.d'), '.mts'],
13-
[pathToFileURL('src/lib/add-ext'), 'mjs']
14-
])('should return `input` with new extension (%#)', (input, ext) => {
11+
[new URL('file:///dist/lib/add-ext.d'), '.mts'],
12+
[new URL('file:///src/lib/add-ext'), 'mjs']
13+
])('should return `input` with new extension (%j, %j)', (input, ext) => {
1514
// Act
1615
const result = testSubject(input, ext)
1716

@@ -22,9 +21,9 @@ describe('unit:lib/addExt', () => {
2221
})
2322

2423
it.each<[URL, string | null | undefined]>([
25-
[pathToFileURL('dist/lib/add-ext.mjs'), ''],
26-
[pathToFileURL('dist/lib/add-ext.d.mts'), '.mts']
27-
])('should return `input` without modications (%#)', (input, ext) => {
24+
[new URL('file:///dist/lib/add-ext.mjs'), ''],
25+
[new URL('file:///dist/lib/add-ext.d.mts'), '.mts']
26+
])('should return `input` without modications (%j, %j)', (input, ext) => {
2827
// Arrange
2928
const clone: URL = new URL(input)
3029

src/lib/__tests__/change-ext.spec.mts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@
55

66
import testSubject from '#lib/change-ext'
77
import formatExt from '#lib/format-ext'
8-
import pathToFileURL from '#lib/path-to-file-url'
98
import type { EmptyString } from '@flex-development/pathe'
109

1110
describe('unit:lib/changeExt', () => {
1211
it.each<[URL, string]>([
13-
[pathToFileURL('/change-ext'), 'mjs'],
14-
[pathToFileURL('/change-ext.'), '.mjs'],
15-
[pathToFileURL('/change-ext.min.cjs'), '.mjs'],
16-
[pathToFileURL('/change-ext.mts'), 'd.mts']
17-
])('should return `input` with changed extension (%#)', (input, ext) => {
12+
[new URL('file:///change-ext'), 'mjs'],
13+
[new URL('file:///change-ext.'), '.mjs'],
14+
[new URL('file:///change-ext.min.cjs'), '.mjs'],
15+
[new URL('file:///change-ext.mts'), 'd.mts']
16+
])('should return `input` with changed extension (%j, %j)', (input, ext) => {
1817
// Act
1918
const result = testSubject(input, ext)
2019

@@ -24,10 +23,10 @@ describe('unit:lib/changeExt', () => {
2423
expect(result).to.have.property('href').endWith(result.pathname)
2524
})
2625

27-
it.each<[URL, (EmptyString | null | undefined)?]>([
28-
[pathToFileURL('/change-ext.cjs'), ''],
29-
[pathToFileURL('/change-ext.mjs'), null]
30-
])('should return `input` without extension (%#)', (input, ext) => {
26+
it.each<[URL, EmptyString | null]>([
27+
[new URL('file:///change-ext.cjs'), ''],
28+
[new URL('file:///change-ext.mjs'), null]
29+
])('should return `input` without extension (%j, %j)', (input, ext) => {
3130
// Act
3231
const result = testSubject(input, ext)
3332

src/lib/__tests__/ext-to-value.spec.mts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import changeExt from '#lib/change-ext'
77
import testSubject from '#lib/ext-to-value'
8-
import pathToFileURL from '#lib/path-to-file-url'
98
import removeExt from '#lib/remove-ext'
109
import type { EmptyString, Ext } from '@flex-development/pathe'
1110
import type { Loader } from 'esbuild'
@@ -21,7 +20,7 @@ describe('unit:lib/extToValue', () => {
2120
['.npmrc', 'copy'],
2221
[changeExt(import.meta.url, 'cts'), undefined],
2322
[import.meta.url, 'ts'],
24-
[pathToFileURL('dist/lib/ext-to-value.d.mts'), 'copy'],
23+
[new URL('file:///dist/lib/ext-to-value.d.mts'), 'copy'],
2524
[removeExt(import.meta.url, 'spec.mts'), 'ts']
2625
])('should return value based on file extension of `input` (%#)', (
2726
input,

src/lib/__tests__/is-absolute.spec.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @file Unit Tests - isAbsolute
33
* @module pathe/lib/tests/unit/isAbsolute
4-
* @see https://github.com/nodejs/node/blob/v23.2.0/test/parallel/test-path-isabsolute.js
4+
* @see https://github.com/nodejs/node/blob/v23.4.0/test/parallel/test-path-isabsolute.js
55
*/
66

77
import testSubject from '#lib/is-absolute'

src/lib/__tests__/join.spec.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @file Unit Tests - join
33
* @module pathe/lib/tests/unit/join
4-
* @see https://github.com/nodejs/node/blob/v23.2.0/test/parallel/test-path-join.js
4+
* @see https://github.com/nodejs/node/blob/v23.4.0/test/parallel/test-path-join.js
55
*/
66

77
import dot from '#lib/dot'

src/lib/__tests__/matches-glob.functional.spec.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @file Functional Tests - matchesGlob
33
* @module pathe/lib/tests/functional/matchesGlob
4-
* @see https://github.com/nodejs/node/blob/v23.2.0/test/parallel/test-path-glob.js
4+
* @see https://github.com/nodejs/node/blob/v23.4.0/test/parallel/test-path-glob.js
55
*/
66

77
import process from '#internal/process'

src/lib/__tests__/normalize.spec.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @file Unit Tests - normalize
33
* @module pathe/lib/tests/unit/normalize
4-
* @see https://github.com/nodejs/node/blob/v23.2.0/test/parallel/test-path-normalize.js
4+
* @see https://github.com/nodejs/node/blob/v23.4.0/test/parallel/test-path-normalize.js
55
*/
66

77
import testSubject from '#lib/normalize'

src/lib/__tests__/path-to-file-url.spec.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @file Unit Tests - pathToFileURL
33
* @module pathe/lib/tests/unit/pathToFileURL
4-
* @see https://github.com/nodejs/node/blob/v23.2.0/test/parallel/test-url-pathtofileurl.js
4+
* @see https://github.com/nodejs/node/blob/v23.4.0/test/parallel/test-url-pathtofileurl.js
55
*/
66

77
import DRIVE from '#fixtures/drive'

src/lib/__tests__/to-namespaced-path.spec.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @file Unit Tests - toNamespacedPath
33
* @module pathe/lib/tests/unit/toNamespacedPath
4-
* @see https://github.com/nodejs/node/blob/v23.2.0/test/parallel/test-path-makelong.js
4+
* @see https://github.com/nodejs/node/blob/v23.4.0/test/parallel/test-path-makelong.js
55
*/
66

77
import process from '#internal/process'

0 commit comments

Comments
 (0)