From 9f4b26f9988db0549ef7410986d2fb4f2b8e5382 Mon Sep 17 00:00:00 2001 From: storywithoutend Date: Wed, 27 Jul 2022 00:04:50 +0800 Subject: [PATCH] fix tests affected by new Backdrop --- components/src/components/molecules/Backdrop/Backdrop.tsx | 7 +++---- components/src/components/molecules/Modal/Modal.test.tsx | 4 +++- components/src/components/organisms/Dialog/Dialog.test.tsx | 2 ++ components/src/components/organisms/Toast/Toast.test.tsx | 2 ++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/components/src/components/molecules/Backdrop/Backdrop.tsx b/components/src/components/molecules/Backdrop/Backdrop.tsx index 659ccb79..12324b7d 100644 --- a/components/src/components/molecules/Backdrop/Backdrop.tsx +++ b/components/src/components/molecules/Backdrop/Backdrop.tsx @@ -55,10 +55,9 @@ export const Backdrop = ({ if (typeof window !== 'undefined' && open) { document.body.style.position = '' document.body.style.top = '' - if (window.scroll) - window.scroll({ - top, - }) + window.scroll({ + top, + }) } } // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/components/src/components/molecules/Modal/Modal.test.tsx b/components/src/components/molecules/Modal/Modal.test.tsx index 575d4a58..43750ab9 100644 --- a/components/src/components/molecules/Modal/Modal.test.tsx +++ b/components/src/components/molecules/Modal/Modal.test.tsx @@ -4,8 +4,10 @@ import { ThemeProvider } from 'styled-components' import { cleanup, render, screen, waitFor } from '@/test' -import { Modal } from './Modal' import { lightTheme } from '@/src/tokens' +import { Modal } from './Modal' + +window.scroll = jest.fn() describe('', () => { afterEach(cleanup) diff --git a/components/src/components/organisms/Dialog/Dialog.test.tsx b/components/src/components/organisms/Dialog/Dialog.test.tsx index 8298399c..ac6c685b 100644 --- a/components/src/components/organisms/Dialog/Dialog.test.tsx +++ b/components/src/components/organisms/Dialog/Dialog.test.tsx @@ -7,6 +7,8 @@ import { cleanup, render, screen, userEvent, waitFor } from '@/test' import { Dialog } from './Dialog' import { lightTheme } from '@/src/tokens' +window.scroll = jest.fn() + describe('', () => { afterEach(cleanup) diff --git a/components/src/components/organisms/Toast/Toast.test.tsx b/components/src/components/organisms/Toast/Toast.test.tsx index c4728baa..4b87aa69 100644 --- a/components/src/components/organisms/Toast/Toast.test.tsx +++ b/components/src/components/organisms/Toast/Toast.test.tsx @@ -7,6 +7,8 @@ import { cleanup, render, screen, userEvent, waitFor } from '@/test' import { Toast } from './Toast' import { lightTheme } from '@/src/tokens' +window.scroll = jest.fn() + describe('', () => { afterEach(cleanup)