Skip to content

Commit 374a0f6

Browse files
committed
test: fix tests
1 parent 3b20f33 commit 374a0f6

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

test/search.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import { resolve } from 'path'
2-
import { Context } from '../src/context'
2+
import { Context } from '../src/core/context'
3+
4+
const root = resolve(__dirname, '../examples/vite-vue3')
35

46
function cleanup(data: any) {
57
return Object.values(data).map((e: any) => {
68
delete e.absolute
9+
e.path = e.path.replace(root, '')
710
return e
811
}).sort((a, b) => (a.name as string).localeCompare(b.name))
912
}
1013

1114
describe('search', () => {
1215
it('should work', async() => {
13-
const ctx = new Context({}, { root: resolve(__dirname, '../examples/vue3') } as any)
16+
const ctx = new Context({})
17+
ctx.setRoot(root)
1418
ctx.searchGlob()
1519

1620
expect(cleanup(ctx.componentNameMap)).toMatchSnapshot()
@@ -20,7 +24,8 @@ describe('search', () => {
2024
const ctx = new Context({
2125
directoryAsNamespace: true,
2226
globalNamespaces: ['global'],
23-
}, { root: resolve(__dirname, '../examples/vue3') } as any)
27+
})
28+
ctx.setRoot(root)
2429
ctx.searchGlob()
2530

2631
expect(cleanup(ctx.componentNameMap)).toMatchSnapshot()

test/stringifyComponentImport.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Context } from '../src/context'
2-
import { stringifyComponentImport } from '../src/utils'
1+
import { Context } from '../src/core/context'
2+
import { stringifyComponentImport } from '../src/core/utils'
33

44
describe('stringifyComponentImport', () => {
55
it('importName', async() => {
6-
const ctx = new Context({}, { root: '' } as any)
6+
const ctx = new Context({})
77
expect(
88
stringifyComponentImport({
99
name: 'Test',
@@ -14,7 +14,7 @@ describe('stringifyComponentImport', () => {
1414
})
1515

1616
it('plain css sideEffects', async() => {
17-
const ctx = new Context({}, { root: '' } as any)
17+
const ctx = new Context({})
1818
expect(
1919
stringifyComponentImport({
2020
name: 'Test',
@@ -25,7 +25,7 @@ describe('stringifyComponentImport', () => {
2525
})
2626

2727
it('multiple sideEffects', async() => {
28-
const ctx = new Context({}, { root: '' } as any)
28+
const ctx = new Context({})
2929
expect(
3030
stringifyComponentImport({
3131
name: 'Test',

0 commit comments

Comments
 (0)