From 2e997265f0a1c9453872ecba2940192456f1c664 Mon Sep 17 00:00:00 2001 From: Aaron Raimist Date: Wed, 9 Feb 2022 07:44:19 +0000 Subject: [PATCH 1/2] Create mock implementation of navigator.registerProtocolHandler for jest Maybe this will fix the tests for https://github.com/matrix-org/matrix-react-sdk/pull/7700 Signed-off-by: Aaron Raimist --- test/jest-mocks.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/jest-mocks.js b/test/jest-mocks.js index 6e1ea8a6051..3bd53754a47 100644 --- a/test/jest-mocks.js +++ b/test/jest-mocks.js @@ -13,5 +13,9 @@ Object.defineProperty(window, 'matchMedia', { })), }); +Object.defineProperty(navigator, 'registerProtocolHandler', { + value: jest.fn().mockImplementation(), +}); + // maplibre requires a createObjectURL mock global.URL.createObjectURL = jest.fn(); From 57ebb6575678986379abbc28672860389e48b2bb Mon Sep 17 00:00:00 2001 From: Aaron Raimist Date: Wed, 9 Feb 2022 08:03:07 +0000 Subject: [PATCH 2/2] Try again Signed-off-by: Aaron Raimist --- test/jest-mocks.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/jest-mocks.js b/test/jest-mocks.js index 3bd53754a47..40ad2113a69 100644 --- a/test/jest-mocks.js +++ b/test/jest-mocks.js @@ -13,9 +13,7 @@ Object.defineProperty(window, 'matchMedia', { })), }); -Object.defineProperty(navigator, 'registerProtocolHandler', { - value: jest.fn().mockImplementation(), -}); +navigator.registerProtocolHandler = jest.fn(); // maplibre requires a createObjectURL mock global.URL.createObjectURL = jest.fn();