From bee3accf6fc9857462d7dd959bc0e8e791691c90 Mon Sep 17 00:00:00 2001 From: DiegoAndai Date: Fri, 6 Sep 2024 13:51:46 -0400 Subject: [PATCH] Add test --- .../mui-material/src/Dialog/Dialog.test.js | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/packages/mui-material/src/Dialog/Dialog.test.js b/packages/mui-material/src/Dialog/Dialog.test.js index a0eb5c3d8ee823..a25e0541f6bd8e 100644 --- a/packages/mui-material/src/Dialog/Dialog.test.js +++ b/packages/mui-material/src/Dialog/Dialog.test.js @@ -318,6 +318,39 @@ describe('', () => { ); expect(getByTestId('paper')).not.to.have.class(classes.paperFullScreen); }); + + it('scrolls if overflown on the Y axis', function test() { + if (/jsdom/.test(window.navigator.userAgent)) { + this.skip(); + } + + const ITEM_HEIGHT = 100; + const ITEM_COUNT = 10; + + const { getByTestId } = render( + + {Array.from(Array(ITEM_COUNT).keys()).map((item) => ( +
+ {item} +
+ ))} +
, + ); + const paperElement = getByTestId('paper'); + expect(paperElement.scrollTop).to.equal(0); + expect(paperElement.clientHeight).to.equal(ITEM_HEIGHT); + expect(paperElement.scrollHeight).to.equal(ITEM_HEIGHT * ITEM_COUNT); + fireEvent.scroll(getByTestId('paper'), { target: { scrollTop: ITEM_HEIGHT } }); + expect(paperElement.scrollTop).to.equal(ITEM_HEIGHT); + }); }); describe('prop: PaperProps.className', () => {