Stub geolocation + matchMedia in OB start-page integration test (P2 regression fix)
This commit is contained in:
@@ -65,6 +65,30 @@ vi.mock("@/ui/city-autocomplete/index.js", () => ({
|
||||
describe("Start page integration", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// Stub matchMedia for useIsMobileViewport (jsdom doesn't implement it).
|
||||
Object.defineProperty(window, "matchMedia", {
|
||||
value: vi.fn().mockImplementation((query: string) => ({
|
||||
matches: false,
|
||||
media: query,
|
||||
addEventListener: () => {},
|
||||
removeEventListener: () => {},
|
||||
dispatchEvent: () => false,
|
||||
})),
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
// Stub geolocation for useGeoCityDefault (jsdom doesn't implement it).
|
||||
Object.defineProperty(navigator, "geolocation", {
|
||||
value: {
|
||||
getCurrentPosition: vi.fn().mockImplementation(
|
||||
(_s: PositionCallback, onErr: PositionErrorCallback) => {
|
||||
onErr({ code: 1, message: "denied" } as GeolocationPositionError);
|
||||
},
|
||||
),
|
||||
},
|
||||
configurable: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("renders the page layout with data-testid", () => {
|
||||
|
||||
Reference in New Issue
Block a user