-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
620733f
commit 6f9b2ce
Showing
3 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { expect } from '@esm-bundle/chai'; | ||
import { fixtureSync, nextFrame } from '@vaadin/testing-helpers'; | ||
import '../all-imports.js'; | ||
import { flushGrid, getBodyCellContent } from './helpers.js'; | ||
|
||
class GridWrapper extends HTMLElement { | ||
constructor() { | ||
super(); | ||
this.attachShadow({ mode: 'open' }).innerHTML = ` | ||
<vaadin-grid id="grid"> | ||
<vaadin-grid-column-group> | ||
<slot name="group"></slot> | ||
</vaadin-grid-column-group> | ||
<slot></slot> | ||
</vaadin-grid> | ||
`; | ||
} | ||
} | ||
|
||
customElements.define('grid-wrapper', GridWrapper); | ||
|
||
async function initGrid(wrapper) { | ||
const grid = wrapper.shadowRoot.querySelector('vaadin-grid'); | ||
grid.items = Array.from({ length: 10 }).map((_, i) => ({ name: `Person ${i}` })); | ||
flushGrid(grid); | ||
await nextFrame(); | ||
return grid; | ||
} | ||
|
||
describe('columns slotted in custom element', () => { | ||
it('should render column correctly with auto-width defined', async () => { | ||
const wrapper = fixtureSync( | ||
'<grid-wrapper><vaadin-grid-column path="name" auto-width></vaadin-grid-column></grid-wrapper>', | ||
); | ||
const grid = await initGrid(wrapper); | ||
|
||
expect(getBodyCellContent(grid, 0, 0).textContent).to.equal('Person 0'); | ||
}); | ||
|
||
it('should render column correctly with auto-width inside a column-group', async () => { | ||
const wrapper = fixtureSync( | ||
'<grid-wrapper><vaadin-grid-column slot="group" path="name" auto-width></vaadin-grid-column></grid-wrapper>', | ||
); | ||
const grid = await initGrid(wrapper); | ||
|
||
expect(getBodyCellContent(grid, 0, 0).textContent).to.equal('Person 0'); | ||
}); | ||
|
||
it('should render column correctly when text-align is defined', async () => { | ||
const wrapper = fixtureSync( | ||
'<grid-wrapper-delayed><vaadin-grid-column path="name" text-align="end"></vaadin-grid-column></grid-wrapper-delayed>', | ||
); | ||
// Delaying the definition of the custom-element so internal <vaadin-grid> is not yet defined | ||
customElements.define('grid-wrapper-delayed', class extends GridWrapper {}); | ||
|
||
const grid = await initGrid(wrapper); | ||
|
||
expect(getBodyCellContent(grid, 0, 0).textContent).to.equal('Person 0'); | ||
}); | ||
}); |