Skip to content

Commit 2511a4c

Browse files
committed
test: updated unit test
1 parent 6ff8cf0 commit 2511a4c

File tree

3 files changed

+212
-629
lines changed

3 files changed

+212
-629
lines changed

packages/core/runtime/__test__/process-css.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ describe('process css', () => {
182182
content: 'content foo color',
183183
lang: 'scss',
184184
}
185-
mockCssFiles.set(transformSymbol(resolve('/play/src/assets/test.css')), mockCSSFilesContent)
185+
mockCssFiles.set(transformSymbol('/play/src/assets/test.css'), mockCSSFilesContent)
186186
const mockDescriptor = {
187187
styles: [{
188188
content: '@import "@/assets/test";\n'
@@ -191,7 +191,7 @@ describe('process css', () => {
191191
+ ' }',
192192
}],
193193
}
194-
const mockId = transformSymbol(resolve('/play/src/App.vue'))
194+
const mockId = transformSymbol('/play/src/App.vue')
195195
const res = getVBindVariableListByPath(
196196
mockDescriptor as any,
197197
mockId,
@@ -296,7 +296,7 @@ describe('handleAlias function', () => {
296296
const path = 'path/to/some/file'
297297
const alias = { '@': 'alias-path' }
298298
const idDirPath = '/some/directory'
299-
expect(handleAlias(path, alias, idDirPath)).toBe('/some/directory/path/to/some/file')
299+
expect(handleAlias(path, alias, idDirPath)).toContain('/some/directory/path/to/some/file')
300300
})
301301

302302
test('idDirPath & alias matched', () => {
@@ -309,6 +309,6 @@ describe('handleAlias function', () => {
309309
test('no alias and idDirPath', () => {
310310
const path = 'path/to/some/file'
311311
const idDirPath = '/some/directory'
312-
expect(handleAlias(path, undefined, idDirPath)).toBe('/some/directory/path/to/some/file')
312+
expect(handleAlias(path, undefined, idDirPath)).toContain('/some/directory/path/to/some/file')
313313
})
314314
})

packages/core/runtime/process-css.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { parse, resolve } from 'path'
2-
import { SUPPORT_FILE, completeSuffix, setTArray } from '@unplugin-vue-cssvars/utils'
2+
import { SUPPORT_FILE, completeSuffix, setTArray, transformSymbol } from '@unplugin-vue-cssvars/utils'
33
import { parseImports } from '../parser'
44
import type { ICSSFile, ICSSFileMap } from '../types'
55
import type { SFCDescriptor } from '@vue/compiler-sfc'
@@ -99,5 +99,5 @@ export function handleAlias(path: string, alias?: Record<string, string>, idDirP
9999
} else {
100100
idDirPath && (importerPath = resolve(idDirPath, path))
101101
}
102-
return importerPath
102+
return transformSymbol(importerPath)
103103
}

0 commit comments

Comments
 (0)