Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoAndai committed Sep 6, 2024
1 parent 63cee05 commit 0ef658f
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions packages/mui-material/src/Dialog/Dialog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,39 @@ describe('<Dialog />', () => {
);
expect(getByTestId('paper')).not.to.have.class(classes.paperFullScreen);
});

it.only('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(
<Dialog
open
fullScreen
PaperProps={{ 'data-testid': 'paper', sx: { height: ITEM_HEIGHT } }}
>
{Array.from(Array(ITEM_COUNT).keys()).map((item) => (
<div
key={item}
style={{ flexShrink: 0, height: ITEM_HEIGHT }}
data-testid={`item-${item}`}
>
{item}
</div>
))}
</Dialog>,
);
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', () => {
Expand Down

0 comments on commit 0ef658f

Please sign in to comment.