Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
cherniavskii committed Jun 12, 2024
1 parent e48c978 commit f026a3e
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,29 @@ describe('<DataGridPro /> - Detail panel', () => {
expect(screen.getByTestId(`detail-panel-content`).textContent).to.equal(`${counter}`);
});

it("should not render detail panel for the focused row if it's outside of the viewport", function test() {
if (isJSDOM) {
this.skip(); // Needs layout
}
render(
<TestCase
getDetailPanelHeight={() => 50}
getDetailPanelContent={() => <div />}
rowBufferPx={0}
nbRows={20}
/>,
);

userEvent.mousePress(screen.getAllByRole('button', { name: 'Expand' })[0]);

const virtualScroller = document.querySelector(`.${gridClasses.virtualScroller}`)!;
virtualScroller.scrollTop = 500;
act(() => virtualScroller.dispatchEvent(new Event('scroll')));

const detailPanels = document.querySelectorAll(`.${gridClasses.detailPanel}`);
expect(detailPanels.length).to.equal(0);
});

describe('prop: onDetailPanelsExpandedRowIds', () => {
it('should call when a row is expanded or closed', () => {
const handleDetailPanelsExpandedRowIdsChange = spy();
Expand Down

0 comments on commit f026a3e

Please sign in to comment.