Skip to content

Commit

Permalink
do not use fake timers for the test
Browse files Browse the repository at this point in the history
  • Loading branch information
cherniavskii committed Mar 2, 2023
1 parent 252d725 commit ad91501
Showing 1 changed file with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { getRow, getCell, getColumnValues } from 'test/utils/helperFn';
const isJSDOM = /jsdom/.test(window.navigator.userAgent);

describe('<DataGridPro /> - Detail panel', () => {
const { render, clock } = createRenderer();
const { render } = createRenderer();

let apiRef: React.MutableRefObject<GridApi>;

Expand Down Expand Up @@ -503,22 +503,20 @@ describe('<DataGridPro /> - Detail panel', () => {
expect(getRow(0)).toHaveComputedStyle({ marginBottom: '502px' }); // 500px + 2px spacing
});

describe('-', () => {
clock.withFakeTimers();

it('should not reuse detail panel components', () => {
function DetailPanel() {
const [today] = React.useState(() => new Date());
return <div>Date is {today.toISOString()}</div>;
}
const { setProps } = render(
<TestCase getDetailPanelContent={() => <DetailPanel />} detailPanelExpandedRowIds={[0]} />,
);
expect(screen.queryByText('Date is 1970-01-01T00:00:00.000Z')).not.to.equal(null);
clock.tick(100);
it('should not reuse detail panel components', () => {
let counter = 0;
function DetailPanel() {
const [number] = React.useState((counter += 1));
return <div data-testid="detail-panel-content">{number}</div>;
}
const { setProps } = render(
<TestCase getDetailPanelContent={() => <DetailPanel />} detailPanelExpandedRowIds={[0]} />,
);
expect(screen.getByTestId(`detail-panel-content`).textContent).to.equal(`${counter}`);
act(() => {
setProps({ detailPanelExpandedRowIds: [1] });
expect(screen.queryByText('Date is 1970-01-01T00:00:00.100Z')).not.to.equal(null);
});
expect(screen.getByTestId(`detail-panel-content`).textContent).to.equal(`${counter}`);
});

describe('prop: onDetailPanelsExpandedRowIds', () => {
Expand Down

0 comments on commit ad91501

Please sign in to comment.