-
Notifications
You must be signed in to change notification settings - Fork 13
/
utils.spec.ts
43 lines (39 loc) · 1.06 KB
/
utils.spec.ts
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
import { describe, expect, it } from 'vitest'
import { normalizeAliases, filename } from '../src/utils'
describe('normalizeAliases', () => {
it('should work', () => {
expect(normalizeAliases({
'@foo/bar': '@foo/bar/dist/index.mjs',
'@foo/bar/utils': '@foo/bar/dist/utils.mjs',
'@': '/root',
bingpot: '@/bingpot/index.ts',
unchanged: '@bingpot/index.ts'
})).toMatchInlineSnapshot(`
{
"@": "/root",
"@foo/bar": "@foo/bar/dist/index.mjs",
"@foo/bar/utils": "@foo/bar/dist/utils.mjs",
"bingpot": "/root/bingpot/index.ts",
"unchanged": "@bingpot/index.ts",
}
`)
})
})
describe('filename', () => {
const files = {
// POSIX
'test.html': 'test',
'/temp/myfile.html': 'myfile',
'./myfile.html': 'myfile',
// Windows
'C:\\temp\\': undefined,
'C:\\temp\\myfile.html': 'myfile',
'\\temp\\myfile.html': 'myfile',
'.\\myfile.html': 'myfile'
}
for (const file in files) {
it(file, () => {
expect(filename(file)).toEqual(files[file])
})
}
})