-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.function.test.js
48 lines (42 loc) · 1.04 KB
/
index.function.test.js
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
45
46
47
48
import tap from 'tap'
import { fileURLToPath } from 'url'
import { dirname as dirnamePath } from 'path'
import { dirname, filename, join, requireJson, isMain } from './index.js'
const __dirname = dirnamePath(fileURLToPath(import.meta.url))
const __filename = fileURLToPath(import.meta.url)
tap.test('dirname', (t) => {
t.equal(
dirname(import.meta.url),
__dirname,
'dirname should return the current directory'
)
t.end()
})
tap.test('filename', (t) => {
t.equal(
filename(import.meta.url),
__filename,
'filename should return the current file'
)
t.end()
})
tap.test('join', (t) => {
t.equal(
join(import.meta.url, 'a', 'b', 'c'),
`${__dirname}/a/b/c`,
'join should join the given paths'
)
t.end()
})
tap.test('requireJson', (t) => {
t.equal(
requireJson(import.meta.url, './package.json').name,
'@uscreen.de/common-esm',
'requireJson should require a JSON file'
)
t.end()
})
tap.test('isMain', (t) => {
t.equal(isMain(import.meta.url), true, 'isMain should return true')
t.end()
})