1
1
import { path } from '@vuepress/utils'
2
2
import { expect , it , vi } from 'vitest'
3
- import type { AliasDefineHook , Bundler } from '../../src/index.js'
3
+ import type { AliasHook , Bundler , DefineHook } from '../../src/index.js'
4
4
import { createBaseApp , normalizeAliasDefineHook } from '../../src/index.js'
5
5
6
6
const app = createBaseApp ( {
@@ -9,13 +9,19 @@ const app = createBaseApp({
9
9
bundler : { } as Bundler ,
10
10
} )
11
11
12
+ it ( 'should wrap object with a function' , async ( ) => {
13
+ const rawHook : AliasHook [ 'exposed' ] = {
14
+ foo : 'bar' ,
15
+ }
16
+ const normalizedHook = normalizeAliasDefineHook ( rawHook )
17
+ expect ( await normalizedHook ( app , true ) ) . toEqual ( { foo : 'bar' } )
18
+ } )
19
+
12
20
it ( 'should keep function as is' , async ( ) => {
13
- const rawHook : AliasDefineHook [ 'exposed' ] = vi . fn (
14
- ( _app , isServer : boolean ) => ( {
15
- foo : 'bar' ,
16
- isServer,
17
- } ) ,
18
- )
21
+ const rawHook : DefineHook [ 'exposed' ] = vi . fn ( ( _app , isServer : boolean ) => ( {
22
+ foo : 'bar' ,
23
+ isServer,
24
+ } ) )
19
25
const normalizedHook = normalizeAliasDefineHook ( rawHook )
20
26
expect ( await normalizedHook ( app , true ) ) . toEqual ( {
21
27
foo : 'bar' ,
@@ -24,11 +30,3 @@ it('should keep function as is', async () => {
24
30
expect ( rawHook ) . toHaveBeenCalledTimes ( 1 )
25
31
expect ( rawHook ) . toHaveBeenCalledWith ( app , true )
26
32
} )
27
-
28
- it ( 'should wrap object with a function' , async ( ) => {
29
- const rawHook : AliasDefineHook [ 'exposed' ] = {
30
- foo : 'bar' ,
31
- }
32
- const normalizedHook = normalizeAliasDefineHook ( rawHook )
33
- expect ( await normalizedHook ( app , true ) ) . toEqual ( { foo : 'bar' } )
34
- } )
0 commit comments