11import { setupRerender } from 'preact/test-utils' ;
22import { createElement , render , Component } from 'preact' ;
33import { setupScratch , teardown } from '../_util/helpers' ;
4+ import { vi } from 'vitest' ;
45
56/** @jsx createElement */
67
@@ -29,24 +30,26 @@ describe('Component spec', () => {
2930 return < div /> ;
3031 }
3132 }
32- sinon . spy ( ForceUpdateComponent . prototype , 'componentWillUpdate' ) ;
33- sinon . spy ( ForceUpdateComponent . prototype , 'forceUpdate' ) ;
33+ vi . spyOn ( ForceUpdateComponent . prototype , 'componentWillUpdate' ) ;
34+ vi . spyOn ( ForceUpdateComponent . prototype , 'forceUpdate' ) ;
3435 render ( < ForceUpdateComponent /> , scratch ) ;
35- expect ( ForceUpdateComponent . prototype . componentWillUpdate ) . not . to . have
36- . been . called ;
36+ expect (
37+ ForceUpdateComponent . prototype . componentWillUpdate
38+ ) . not . toHaveBeenCalled ( ) ;
3739
3840 forceUpdate ( ) ;
3941 rerender ( ) ;
4042
41- expect ( ForceUpdateComponent . prototype . componentWillUpdate ) . to . have . been
42- . called ;
43- expect ( ForceUpdateComponent . prototype . forceUpdate ) . to . have . been . called ;
43+ expect (
44+ ForceUpdateComponent . prototype . componentWillUpdate
45+ ) . toHaveBeenCalled ( ) ;
46+ expect ( ForceUpdateComponent . prototype . forceUpdate ) . toHaveBeenCalled ( ) ;
4447 } ) ;
4548
4649 it ( 'should add callback to renderCallbacks' , ( ) => {
4750 /** @type {() => void } */
4851 let forceUpdate ;
49- let callback = sinon . spy ( ) ;
52+ let callback = vi . fn ( ) ;
5053 class ForceUpdateComponent extends Component {
5154 componentDidMount ( ) {
5255 forceUpdate = ( ) => this . forceUpdate ( callback ) ;
@@ -55,17 +58,17 @@ describe('Component spec', () => {
5558 return < div /> ;
5659 }
5760 }
58- sinon . spy ( ForceUpdateComponent . prototype , 'forceUpdate' ) ;
61+ vi . spyOn ( ForceUpdateComponent . prototype , 'forceUpdate' ) ;
5962 render ( < ForceUpdateComponent /> , scratch ) ;
6063
6164 forceUpdate ( ) ;
6265 rerender ( ) ;
6366
64- expect ( ForceUpdateComponent . prototype . forceUpdate ) . to . have . been . called ;
65- expect (
66- ForceUpdateComponent . prototype . forceUpdate
67- ) . to . have . been . calledWith ( callback ) ;
68- expect ( callback ) . to . have . been . called ;
67+ expect ( ForceUpdateComponent . prototype . forceUpdate ) . toHaveBeenCalled ( ) ;
68+ expect ( ForceUpdateComponent . prototype . forceUpdate ) . toHaveBeenCalledWith (
69+ callback
70+ ) ;
71+ expect ( callback ) . toHaveBeenCalled ( ) ;
6972 } ) ;
7073 } ) ;
7174} ) ;
0 commit comments