@@ -10,20 +10,29 @@ vi.mock('@vkontakte/vkui-floating-ui/react-dom', () => {
1010 } ;
1111} ) ;
1212
13- const customResizeObserverInstanceStub = {
13+ const customResizeObserverInstanceStub = vi . hoisted ( ( ) => ( {
1414 observe : vi . fn ( ) ,
1515 disconnect : vi . fn ( ) ,
1616 appendToTheDOM : vi . fn ( ) ,
17- } ;
18- const customResizeObserverStub = vi . fn ( ) . mockImplementation ( ( ) => {
19- return customResizeObserverInstanceStub ;
20- } ) ;
17+ } ) ) ;
18+
19+ const CustomResizeObserverStub = vi . hoisted ( ( ) =>
20+ vi . fn (
21+ class MockCustomResizeObserver {
22+ observe = customResizeObserverInstanceStub . observe . bind ( customResizeObserverInstanceStub ) ;
23+ disconnect = customResizeObserverInstanceStub . disconnect . bind (
24+ customResizeObserverInstanceStub ,
25+ ) ;
26+ appendToTheDOM = customResizeObserverInstanceStub . appendToTheDOM . bind (
27+ customResizeObserverInstanceStub ,
28+ ) ;
29+ } ,
30+ ) ,
31+ ) ;
2132
2233vi . mock ( './customResizeObserver' , ( ) => {
2334 return {
24- CustomResizeObserver : vi . fn ( ) . mockImplementation ( ( ) => {
25- return customResizeObserverStub ( ) ;
26- } ) ,
35+ CustomResizeObserver : CustomResizeObserverStub ,
2736 } ;
2837} ) ;
2938
@@ -70,7 +79,7 @@ describe(autoUpdateFloatingElement, () => {
7079 expect . objectContaining ( { elementResize : false } ) ,
7180 ) ;
7281
73- expect ( customResizeObserverStub . mock . instances . length ) . toBe ( 1 ) ;
82+ expect ( CustomResizeObserverStub . mock . instances . length ) . toBe ( 1 ) ;
7483 } ) ;
7584
7685 test ( 'calls disposer in unmount callback' , ( ) => {
0 commit comments