-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathbuilder_spec.ts
38 lines (34 loc) · 1.02 KB
/
builder_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
import { pathToFileURL } from 'node:url'
import path from 'node:path'
import { expect } from 'chai'
import FormatterBuilder from './builder'
describe('custom class loading', () => {
const varieties = [
'legacy_esm.mjs',
'legacy_exports_dot_default.cjs',
'legacy_module_dot_exports.cjs',
]
varieties.forEach((filename) => {
describe(filename, () => {
it('should handle a relative path', async () => {
const CustomClass = await FormatterBuilder.loadCustomClass(
'formatter',
`./fixtures/${filename}`,
__dirname
)
expect(typeof CustomClass).to.eq('function')
})
it('should handle a file:// url', async () => {
const fileUrl = pathToFileURL(
path.resolve(__dirname, `./fixtures/${filename}`)
).toString()
const CustomClass = await FormatterBuilder.loadCustomClass(
'formatter',
fileUrl,
__dirname
)
expect(typeof CustomClass).to.eq('function')
})
})
})
})