-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.function.test.js
More file actions
44 lines (38 loc) · 1.05 KB
/
index.function.test.js
File metadata and controls
44 lines (38 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import assert from 'node:assert/strict'
import { dirname as dirnamePath } from 'node:path'
import { test } from 'node:test'
import { fileURLToPath } from 'node:url'
import { dirname, filename, isMain, join, requireJson } from './index.js'
const __dirname = dirnamePath(fileURLToPath(import.meta.url))
const __filename = fileURLToPath(import.meta.url)
test('dirname', () => {
assert.equal(
dirname(import.meta.url),
__dirname,
'dirname should return the current directory'
)
})
test('filename', () => {
assert.equal(
filename(import.meta.url),
__filename,
'filename should return the current file'
)
})
test('join', () => {
assert.equal(
join(import.meta.url, 'a', 'b', 'c'),
`${__dirname}/a/b/c`,
'join should join the given paths'
)
})
test('requireJson', () => {
assert.equal(
requireJson(import.meta.url, './package.json').name,
'@uscreen.de/common-esm',
'requireJson should require a JSON file'
)
})
test('isMain', () => {
assert.equal(isMain(import.meta.url), true, 'isMain should return true')
})