1
+ import { beforeAll , describe , expect , test , vi } from 'vitest'
2
+
1
3
import { HOOK_TYPE , TaroHook , TaroHooks } from '../src/runtime-hooks'
2
4
import { mergeReconciler } from '../src/utils'
3
5
@@ -13,7 +15,7 @@ describe('taro hooks', () => {
13
15
} )
14
16
} )
15
17
16
- it ( 'single' , ( ) => {
18
+ test ( 'single' , ( ) => {
17
19
hook . tap ( 'hookA' , ( ) => {
18
20
return 'first'
19
21
} )
@@ -24,7 +26,7 @@ describe('taro hooks', () => {
24
26
expect ( res ) . toBe ( 'second' )
25
27
} )
26
28
27
- it ( 'single with default' , ( ) => {
29
+ test ( 'single with default' , ( ) => {
28
30
let res = hook . call ( 'hookAWithDefault' , 'Ben' )
29
31
expect ( res ) . toBe ( 'name: Ben' )
30
32
hook . tap ( 'hookAWithDefault' , ( name ) => {
@@ -34,20 +36,20 @@ describe('taro hooks', () => {
34
36
expect ( res ) . toBe ( 'JoJo' )
35
37
} )
36
38
37
- it ( 'multi' , ( ) => {
38
- const fnA = jest . fn ( )
39
- const fnB = jest . fn ( )
39
+ test ( 'multi' , ( ) => {
40
+ const fnA = vi . fn ( )
41
+ const fnB = vi . fn ( )
40
42
hook . tap ( 'hookB' , fnA )
41
43
hook . tap ( 'hookB' , fnB )
42
44
hook . call ( 'hookB' )
43
45
expect ( fnA ) . toBeCalled ( )
44
46
expect ( fnB ) . toBeCalled ( )
45
47
} )
46
48
47
- it ( 'multi default' , ( ) => {
48
- const fnA = jest . fn ( )
49
- const fnB = jest . fn ( )
50
- const fnC = jest . fn ( )
49
+ test ( 'multi default' , ( ) => {
50
+ const fnA = vi . fn ( )
51
+ const fnB = vi . fn ( )
52
+ const fnC = vi . fn ( )
51
53
const hook = new TaroHooks ( {
52
54
hookBWithDefault : TaroHook ( HOOK_TYPE . MULTI , fnA )
53
55
} )
@@ -59,7 +61,7 @@ describe('taro hooks', () => {
59
61
expect ( fnC ) . toBeCalled ( )
60
62
} )
61
63
62
- it ( 'waterfall' , ( ) => {
64
+ test ( 'waterfall' , ( ) => {
63
65
hook . tap ( 'hookC' , ( obj ) => {
64
66
obj . num += 1
65
67
return obj
@@ -76,7 +78,7 @@ describe('taro hooks', () => {
76
78
expect ( res ) . toEqual ( { num : 16 } )
77
79
} )
78
80
79
- it ( 'plugin' , ( ) => {
81
+ test ( 'plugin' , ( ) => {
80
82
// shared
81
83
const hooks = new TaroHooks ( {
82
84
hookA : TaroHook ( HOOK_TYPE . SINGLE , ( ) => 'default' ) ,
@@ -85,7 +87,7 @@ describe('taro hooks', () => {
85
87
} )
86
88
87
89
// pluginA
88
- const fnA = jest . fn ( )
90
+ const fnA = vi . fn ( )
89
91
const reconcilerA = {
90
92
hookA : ( ) => 'pluginA' ,
91
93
hookB : fnA ,
@@ -94,7 +96,7 @@ describe('taro hooks', () => {
94
96
mergeReconciler ( reconcilerA , hooks )
95
97
96
98
// pluginB
97
- const fnB = jest . fn ( )
99
+ const fnB = vi . fn ( )
98
100
const reconcilerB = {
99
101
hookA : ( ) => 'pluginB' ,
100
102
hookB : fnB ,
0 commit comments