Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Oct 7, 2024
1 parent 9ac8dba commit b1f68d0
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('<DataGridPro /> - Edit components', () => {
});
});

it('should call onValueChange if defined', async () => {
it('should call onValueChange if defined', () => {
const onValueChange = spy();

defaultData.columns[0].renderEditCell = (params) =>
Expand All @@ -137,7 +137,6 @@ describe('<DataGridPro /> - Edit components', () => {
fireEvent.change(input, { target: { value: 'Puma' } });
expect(onValueChange.callCount).to.equal(1);
expect(onValueChange.lastCall.args[1]).to.equal('Puma');
await act(() => Promise.resolve());
});
});

Expand Down Expand Up @@ -272,7 +271,7 @@ describe('<DataGridPro /> - Edit components', () => {
const input = cell.querySelector('input')!;
expect(input.value).to.equal('2022-02-18');
await act(async () => {
await apiRef.current.setEditCellValue({
apiRef.current.setEditCellValue({
id: 0,
field: 'createdAt',
value: new Date(2022, 1, 10),
Expand Down Expand Up @@ -324,7 +323,7 @@ describe('<DataGridPro /> - Edit components', () => {
);
});

it('should call onValueChange if defined', async () => {
it('should call onValueChange if defined', () => {
const onValueChange = spy();

defaultData.columns[0].renderEditCell = (params) =>
Expand All @@ -342,7 +341,6 @@ describe('<DataGridPro /> - Edit components', () => {
expect((onValueChange.lastCall.args[1]! as Date).toISOString()).to.equal(
new Date(2022, 1, 10).toISOString(),
);
await act(() => Promise.resolve());
});
});

Expand Down Expand Up @@ -393,7 +391,7 @@ describe('<DataGridPro /> - Edit components', () => {
const input = cell.querySelector('input')!;
expect(input.value).to.equal('2022-02-18T14:30');
await act(async () => {
await apiRef.current.setEditCellValue({
apiRef.current.setEditCellValue({
id: 0,
field: 'createdAt',
value: new Date(2022, 1, 10, 15, 10, 0),
Expand Down Expand Up @@ -541,7 +539,9 @@ describe('<DataGridPro /> - Edit components', () => {
fireEvent.doubleClick(cell);

expect(cell.textContent!.replace(/[\W]+/, '')).to.equal('Nike'); // We use .replace to remove &ZeroWidthSpace;
await act(() => apiRef.current.setEditCellValue({ id: 0, field: 'brand', value: 'Adidas' }));
await act(() => {
apiRef.current.setEditCellValue({ id: 0, field: 'brand', value: 'Adidas' });
});
expect(cell.textContent!.replace(/[\W]+/, '')).to.equal('Adidas');
});

Expand All @@ -562,7 +562,7 @@ describe('<DataGridPro /> - Edit components', () => {
expect(onValueChange.lastCall.args[1]).to.equal('Adidas');
});

it('should call onCellEditStop', async () => {
it('should call onCellEditStop', () => {
const onCellEditStop = spy();

render(
Expand All @@ -576,7 +576,6 @@ describe('<DataGridPro /> - Edit components', () => {
fireEvent.doubleClick(cell);
fireUserEvent.mousePress(document.getElementById('outside-grid')!);
expect(onCellEditStop.callCount).to.equal(1);
await act(() => Promise.resolve());
});

it('should not open the suggestions when Enter is pressed', async () => {
Expand Down

0 comments on commit b1f68d0

Please sign in to comment.