forked from unplugin/unplugin-vue-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.test.ts
34 lines (28 loc) · 883 Bytes
/
search.test.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
import path from 'pathe'
import { describe, expect, it } from 'vitest'
import { Context } from '../src/core/context'
const root = path.resolve(__dirname, '../examples/vite-vue3')
function cleanup(data: any) {
return Object.values(data).map((e: any) => {
delete e.absolute
e.path = path.relative(root, e.path).replace(/\\/g, '/')
return e
}).sort((a, b) => (a.name as string).localeCompare(b.name))
}
describe('search', () => {
it('should work', async() => {
const ctx = new Context({})
ctx.setRoot(root)
ctx.searchGlob()
expect(cleanup(ctx.componentNameMap)).toMatchSnapshot()
})
it('should with namespace', async() => {
const ctx = new Context({
directoryAsNamespace: true,
globalNamespaces: ['global'],
})
ctx.setRoot(root)
ctx.searchGlob()
expect(cleanup(ctx.componentNameMap)).toMatchSnapshot()
})
})