Skip to content

Commit bee3acc

Browse files
committed
Add test
1 parent 63cee05 commit bee3acc

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

packages/mui-material/src/Dialog/Dialog.test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,39 @@ describe('<Dialog />', () => {
318318
);
319319
expect(getByTestId('paper')).not.to.have.class(classes.paperFullScreen);
320320
});
321+
322+
it('scrolls if overflown on the Y axis', function test() {
323+
if (/jsdom/.test(window.navigator.userAgent)) {
324+
this.skip();
325+
}
326+
327+
const ITEM_HEIGHT = 100;
328+
const ITEM_COUNT = 10;
329+
330+
const { getByTestId } = render(
331+
<Dialog
332+
open
333+
fullScreen
334+
PaperProps={{ 'data-testid': 'paper', sx: { height: ITEM_HEIGHT } }}
335+
>
336+
{Array.from(Array(ITEM_COUNT).keys()).map((item) => (
337+
<div
338+
key={item}
339+
style={{ flexShrink: 0, height: ITEM_HEIGHT }}
340+
data-testid={`item-${item}`}
341+
>
342+
{item}
343+
</div>
344+
))}
345+
</Dialog>,
346+
);
347+
const paperElement = getByTestId('paper');
348+
expect(paperElement.scrollTop).to.equal(0);
349+
expect(paperElement.clientHeight).to.equal(ITEM_HEIGHT);
350+
expect(paperElement.scrollHeight).to.equal(ITEM_HEIGHT * ITEM_COUNT);
351+
fireEvent.scroll(getByTestId('paper'), { target: { scrollTop: ITEM_HEIGHT } });
352+
expect(paperElement.scrollTop).to.equal(ITEM_HEIGHT);
353+
});
321354
});
322355

323356
describe('prop: PaperProps.className', () => {

0 commit comments

Comments
 (0)