From a5f85237b58f74979ff8ca1e131444aae14d33eb Mon Sep 17 00:00:00 2001 From: sam-m-m Date: Mon, 10 Aug 2020 18:07:21 -0700 Subject: [PATCH] Feat #30 - Update: fix snapshot test bug (matchMedia) --- src/setupTests.ts | 14 ++++++++++++++ src/storybook.test.ts | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/setupTests.ts b/src/setupTests.ts index 88c8c3b3..85c38370 100644 --- a/src/setupTests.ts +++ b/src/setupTests.ts @@ -2,3 +2,17 @@ import Enzyme from 'enzyme' import Adapter from 'enzyme-adapter-react-16' Enzyme.configure({ adapter: new Adapter() }) + +Object.defineProperty(window, 'matchMedia', { + writable: true, + value: jest.fn().mockImplementation(query => ({ + matches: false, + media: query, + onchange: null, + addListener: jest.fn(), // deprecated + removeListener: jest.fn(), // deprecated + addEventListener: jest.fn(), + removeEventListener: jest.fn(), + dispatchEvent: jest.fn() + })) +}) diff --git a/src/storybook.test.ts b/src/storybook.test.ts index e4e9f666..a21dea41 100644 --- a/src/storybook.test.ts +++ b/src/storybook.test.ts @@ -1,17 +1,3 @@ import initStoryshots from '@storybook/addon-storyshots' -Object.defineProperty(window, 'matchMedia', { - writable: true, - value: jest.fn().mockImplementation(query => ({ - matches: false, - media: query, - onchange: null, - addListener: jest.fn(), // deprecated - removeListener: jest.fn(), // deprecated - addEventListener: jest.fn(), - removeEventListener: jest.fn(), - dispatchEvent: jest.fn() - })) -}) - initStoryshots()