Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions packages/grid/test/column.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,45 @@
});
});

describe('cell content attach and detach', () => {
['header', 'body', 'footer'].forEach((sectionName) => {
let content;

beforeEach(() => {
if (sectionName === 'header') {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could use switch (sectionName) here with body as default I guess.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 261e04b.

content = getHeaderCellContent(grid, 1, 0);
}
if (sectionName === 'footer') {
content = getContainerCellContent(grid.$.footer, 0, 0);
}
if (sectionName === 'body') {
content = getBodyCellContent(grid, 0, 0);
}
});

it(`should remove ${sectionName} cell content from the grid when column is removed`, async () => {

Check failure on line 522 in packages/grid/test/column.test.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add at least one assertion to this test case.

See more on https://sonarcloud.io/project/issues?id=vaadin_web-components&issues=AZ9wPrVu9cJglEUvM0VH&open=AZ9wPrVu9cJglEUvM0VH&pullRequest=12181
column.remove();
await nextFrame();

expect(content.parentElement).to.be.null;
});
});

it('should render cell content when column is added back', async () => {
const group = column.parentElement;
column.remove();
await nextFrame();

group.insertBefore(column, group.firstElementChild);
await nextFrame();
flushGrid(grid);

expect(getHeaderCellContent(grid, 1, 0).textContent).to.equal('header1');
expect(getContainerCellContent(grid.$.footer, 0, 0).textContent).to.equal('footer1');
expect(getBodyCellContent(grid, 0, 0).textContent).to.equal('cell');
});
});

it('should not throw an exception when size is changed after removing column', () => {
expect(grid.size).to.equal(10);
expect(column.isConnected).to.be.true;
Expand Down
Loading