1+ import { beforeAll , describe , expect , test , vi } from 'vitest'
2+
13import { HOOK_TYPE , TaroHook , TaroHooks } from '../src/runtime-hooks'
24import { mergeReconciler } from '../src/utils'
35
@@ -13,7 +15,7 @@ describe('taro hooks', () => {
1315 } )
1416 } )
1517
16- it ( 'single' , ( ) => {
18+ test ( 'single' , ( ) => {
1719 hook . tap ( 'hookA' , ( ) => {
1820 return 'first'
1921 } )
@@ -24,7 +26,7 @@ describe('taro hooks', () => {
2426 expect ( res ) . toBe ( 'second' )
2527 } )
2628
27- it ( 'single with default' , ( ) => {
29+ test ( 'single with default' , ( ) => {
2830 let res = hook . call ( 'hookAWithDefault' , 'Ben' )
2931 expect ( res ) . toBe ( 'name: Ben' )
3032 hook . tap ( 'hookAWithDefault' , ( name ) => {
@@ -34,20 +36,20 @@ describe('taro hooks', () => {
3436 expect ( res ) . toBe ( 'JoJo' )
3537 } )
3638
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 ( )
4042 hook . tap ( 'hookB' , fnA )
4143 hook . tap ( 'hookB' , fnB )
4244 hook . call ( 'hookB' )
4345 expect ( fnA ) . toBeCalled ( )
4446 expect ( fnB ) . toBeCalled ( )
4547 } )
4648
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 ( )
5153 const hook = new TaroHooks ( {
5254 hookBWithDefault : TaroHook ( HOOK_TYPE . MULTI , fnA )
5355 } )
@@ -59,7 +61,7 @@ describe('taro hooks', () => {
5961 expect ( fnC ) . toBeCalled ( )
6062 } )
6163
62- it ( 'waterfall' , ( ) => {
64+ test ( 'waterfall' , ( ) => {
6365 hook . tap ( 'hookC' , ( obj ) => {
6466 obj . num += 1
6567 return obj
@@ -76,7 +78,7 @@ describe('taro hooks', () => {
7678 expect ( res ) . toEqual ( { num : 16 } )
7779 } )
7880
79- it ( 'plugin' , ( ) => {
81+ test ( 'plugin' , ( ) => {
8082 // shared
8183 const hooks = new TaroHooks ( {
8284 hookA : TaroHook ( HOOK_TYPE . SINGLE , ( ) => 'default' ) ,
@@ -85,7 +87,7 @@ describe('taro hooks', () => {
8587 } )
8688
8789 // pluginA
88- const fnA = jest . fn ( )
90+ const fnA = vi . fn ( )
8991 const reconcilerA = {
9092 hookA : ( ) => 'pluginA' ,
9193 hookB : fnA ,
@@ -94,7 +96,7 @@ describe('taro hooks', () => {
9496 mergeReconciler ( reconcilerA , hooks )
9597
9698 // pluginB
97- const fnB = jest . fn ( )
99+ const fnB = vi . fn ( )
98100 const reconcilerB = {
99101 hookA : ( ) => 'pluginB' ,
100102 hookB : fnB ,
0 commit comments