Skip to content

Commit

Permalink
test: extract common test setup to beforeEach block
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan committed Sep 24, 2024
1 parent 276ba30 commit e848ab7
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions test/integration/grid-pro-custom-editor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,36 +63,31 @@ describe('grid-pro custom editor', () => {
});

describe('date-picker', () => {
it('should apply the updated date to the cell when exiting on Tab', async () => {
const cell = getContainerCell(grid.$.items, 0, 2);
let cell;

beforeEach(async () => {
cell = getContainerCell(grid.$.items, 0, 2);
cell.focus();

await sendKeys({ press: 'Enter' });
});

it('should apply the updated date to the cell when exiting on Tab', async () => {
await sendKeys({ type: '1/12/1984' });
await sendKeys({ press: 'Tab' });

expect(cell._content.textContent).to.equal('1984-01-12');
});

it('should apply the updated date to the cell when exiting on Enter', async () => {
const cell = getContainerCell(grid.$.items, 0, 2);
cell.focus();

await sendKeys({ press: 'Enter' });

await sendKeys({ type: '1/12/1984' });
await sendKeys({ press: 'Enter' });

expect(cell._content.textContent).to.equal('1984-01-12');
});

it('should not stop editing on input click when focus is in the overlay', async () => {
const cell = getContainerCell(grid.$.items, 0, 2);
cell.focus();

await sendKeys({ press: 'Enter' });

// Open the overlay
await sendKeys({ press: 'ArrowDown' });

const { x, y } = middleOfNode(cell._content.querySelector('input'));
Expand All @@ -102,11 +97,6 @@ describe('grid-pro custom editor', () => {
});

it('should stop editing and update value when closing on outside click', async () => {
const cell = getContainerCell(grid.$.items, 0, 2);
cell.focus();

await sendKeys({ press: 'Enter' });

// Open the overlay
await sendKeys({ press: 'ArrowDown' });
await waitForOverlayRender();
Expand Down

0 comments on commit e848ab7

Please sign in to comment.