Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/__mocks__/match_media_mock.js')
-rw-r--r--spec/frontend/__mocks__/match_media_mock.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/frontend/__mocks__/match_media_mock.js b/spec/frontend/__mocks__/match_media_mock.js
new file mode 100644
index 00000000..0f2d0192
--- /dev/null
+++ b/spec/frontend/__mocks__/match_media_mock.js
@@ -0,0 +1,15 @@
+/**
+ * Mock matchMedia since it is not available in JSDOM.
+ * https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
+ */
+Object.defineProperty(window, 'matchMedia', {
+ writable: true,
+ value: jest.fn().mockImplementation((query) => ({
+ matches: false,
+ media: query,
+ onchange: null,
+ addEventListener: jest.fn(),
+ removeEventListener: jest.fn(),
+ dispatchEvent: jest.fn(),
+ })),
+});