Skip to content

Commit

Permalink
[test] Fix tests (#1928)
Browse files Browse the repository at this point in the history
  • Loading branch information
m4theushw authored Jun 18, 2021
1 parent a5974e7 commit 5b5287c
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions packages/grid/x-grid/src/tests/editRows.XGrid.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ describe('<XGrid /> - Edit Rows', () => {
const cell = getCell(1, 1);
cell.focus();
fireEvent.doubleClick(cell);
expect(cell).to.have.class('MuiDataGrid-cellEditing');
expect(cell).to.have.class('MuiDataGrid-cell--editing');

const otherCell = getCell(2, 1);
fireEvent.click(otherCell);
fireEvent.focus(otherCell);
expect(cell).to.have.class('MuiDataGrid-cellEditing');
expect(cell).to.have.class('MuiDataGrid-cell--editing');
});

it('should allow to switch between cell mode using enter key', () => {
Expand Down Expand Up @@ -271,7 +271,7 @@ describe('<XGrid /> - Edit Rows', () => {
const otherCell = getCell(2, 1);
fireEvent.click(otherCell);
fireEvent.focus(otherCell);
expect(cell).not.to.have.class('MuiDataGrid-cellEditing');
expect(cell).not.to.have.class('MuiDataGrid-cell--editing');
expect(cell).to.have.text('1970');
expect(getActiveCell()).to.equal('2-1');
});
Expand All @@ -290,7 +290,7 @@ describe('<XGrid /> - Edit Rows', () => {

const columnHeader = getColumnHeaderCell(0);
fireEvent.dragStart(columnHeader.firstChild);
expect(cell).not.to.have.class('MuiDataGrid-cellEditing');
expect(cell).not.to.have.class('MuiDataGrid-cell--editing');
expect(cell).to.have.text('1970');
});

Expand All @@ -307,7 +307,7 @@ describe('<XGrid /> - Edit Rows', () => {
expect(cell.querySelector('input')!.value).to.equal('1970');

fireEvent.focus(getColumnHeaderCell(1));
expect(cell).not.to.have.class('MuiDataGrid-cellEditing');
expect(cell).not.to.have.class('MuiDataGrid-cell--editing');
expect(cell).to.have.text('1970');
});

Expand All @@ -325,7 +325,7 @@ describe('<XGrid /> - Edit Rows', () => {
const otherCell = getCell(2, 1);
fireEvent.click(otherCell);
fireEvent.focus(otherCell);
expect(cell).not.to.have.class('MuiDataGrid-cellEditing');
expect(cell).not.to.have.class('MuiDataGrid-cell--editing');
expect(cell).to.have.text('1970');
expect(getActiveCell()).to.equal('2-1');
});
Expand Down Expand Up @@ -408,12 +408,12 @@ describe('<XGrid /> - Edit Rows', () => {
/>,
);
const cell = getCell(0, 0);
expect(cell).not.to.have.class('MuiDataGrid-cellEditing');
expect(cell).not.to.have.class('MuiDataGrid-cell--editing');
fireEvent.doubleClick(cell);
expect(cell).to.have.class('MuiDataGrid-cellEditing');
expect(cell).to.have.class('MuiDataGrid-cell--editing');
fireEvent.mouseUp(screen.getByRole('button', { name: /Click me/i }));
fireEvent.click(screen.getByRole('button', { name: /Click me/i }));
expect(cell).to.have.class('MuiDataGrid-cellEditing');
expect(cell).to.have.class('MuiDataGrid-cell--editing');
});

it('should stay in the edit mode when the element inside the cell triggers click but no mouseup', () => {
Expand All @@ -429,12 +429,12 @@ describe('<XGrid /> - Edit Rows', () => {
/>,
);
const cell = getCell(0, 0);
expect(cell).not.to.have.class('MuiDataGrid-cellEditing');
expect(cell).not.to.have.class('MuiDataGrid-cell--editing');
fireEvent.doubleClick(cell);
expect(cell).to.have.class('MuiDataGrid-cellEditing');
expect(cell).to.have.class('MuiDataGrid-cell--editing');
const checkbox = screen.getByRole('checkbox');
fireEvent.click(checkbox);
expect(cell).to.have.class('MuiDataGrid-cellEditing');
expect(cell).to.have.class('MuiDataGrid-cell--editing');
});

it('should support getRowId', () => {
Expand All @@ -454,8 +454,8 @@ describe('<XGrid /> - Edit Rows', () => {
expect(cell.querySelector('input')!.value).to.equal('n');

fireEvent.keyDown(input, { key: 'Enter' });
expect(cell).to.have.class('MuiDataGrid-cellEditable');
expect(cell).not.to.have.class('MuiDataGrid-cellEditing');
expect(cell).to.have.class('MuiDataGrid-cell--editable');
expect(cell).not.to.have.class('MuiDataGrid-cell--editing');
expect(cell).to.have.text('n');
expect(screen.queryAllByRole('row')).to.have.length(4);
});
Expand Down

0 comments on commit 5b5287c

Please sign in to comment.