File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -17,9 +17,22 @@ import userEvent from "@testing-library/user-event";
1717import { getPlatform } from "../../utils/platform" ;
1818
1919vi . mock ( "../../utils/platform" , ( ) => ( { getPlatform : vi . fn ( ( ) => "other" ) } ) ) ;
20- vi . spyOn ( window , "matchMedia" ) . mockReturnValue ( {
21- matches : false ,
22- } as unknown as MediaQueryList ) ;
20+ vi . hoisted ( ( ) => {
21+ Object . defineProperty ( window , "matchMedia" , {
22+ writable : true ,
23+ enumerable : true ,
24+ value : vi . fn ( ) . mockImplementation ( ( query ) => ( {
25+ matches : false ,
26+ media : query ,
27+ onchange : null ,
28+ addListener : vi . fn ( ) , // deprecated
29+ removeListener : vi . fn ( ) , // deprecated
30+ addEventListener : vi . fn ( ) ,
31+ removeEventListener : vi . fn ( ) ,
32+ dispatchEvent : vi . fn ( ) ,
33+ } ) ) ,
34+ } ) ;
35+ } ) ;
2336
2437async function withPlatform (
2538 platform : ReturnType < typeof getPlatform > ,
You can’t perform that action at this time.
0 commit comments