-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
va-table: add striped variation #1439
Changes from all commits
88d095a
e5eb9ae
f6a73ed
04f8ed5
0b8d397
31c6de5
e61e300
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,11 @@ import { dateSort } from '../../sort/date'; | |
import { _getCompareFunc } from '../../sort/utils'; | ||
|
||
describe('va-table', () => { | ||
function makeTable() { | ||
return `<va-table table-title="this is a caption"> | ||
function makeTable(props = {}) { | ||
const defaultProps = {...props, 'table-title': 'this is a caption'}; | ||
return `<va-table ${Object.entries(defaultProps) | ||
.map(([key, value]) => `${key}="${value}"`) | ||
.join(' ')}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I saw an opportunity to make it easier to test props without having to copy/paste table markup. We should be able to use this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks great! |
||
<va-table-row> | ||
<span>One</span> | ||
<span>Two</span> | ||
|
@@ -61,39 +64,15 @@ describe('va-table', () => { | |
|
||
it('is scrollable when attribute is set to true', async () => { | ||
const page = await newE2EPage(); | ||
await page.setContent(`<va-table scrollable="true" table-title="this is a caption"> | ||
<va-table-row> | ||
<span>One</span> | ||
<span>Two</span> | ||
<span>Three</span> | ||
</va-table-row> | ||
|
||
<va-table-row> | ||
<span>Dog</span> | ||
<span>Cat</span> | ||
<span>Mouse</span> | ||
</va-table-row> | ||
</va-table>`); | ||
await page.setContent(makeTable({scrollable: 'true'})); | ||
const table = await page.find('va-table-inner >>> div'); | ||
expect(table.getAttribute('tabindex')).toEqual('0'); | ||
expect(table).toHaveClass('usa-table-container--scrollable'); | ||
}); | ||
|
||
it('is not stacked by when attribute is set to false', async () => { | ||
const page = await newE2EPage(); | ||
await page.setContent(`<va-table stacked="false" table-title="this is a caption"> | ||
<va-table-row> | ||
<span>One</span> | ||
<span>Two</span> | ||
<span>Three</span> | ||
</va-table-row> | ||
|
||
<va-table-row> | ||
<span>Dog</span> | ||
<span>Cat</span> | ||
<span>Mouse</span> | ||
</va-table-row> | ||
</va-table>`); | ||
await page.setContent(makeTable({stacked: 'false'})); | ||
const table = await page.find('va-table-inner >>> table'); | ||
expect(table).not.toHaveClass('usa-table--stacked'); | ||
}); | ||
|
@@ -123,6 +102,20 @@ describe('va-table', () => { | |
expect(columnHeader.getAttribute('scope')).toEqual('col'); | ||
expect(rowHeader.getAttribute('scope')).toEqual('row'); | ||
}); | ||
|
||
it('is not striped by default', async () => { | ||
const page = await newE2EPage(); | ||
await page.setContent(makeTable()); | ||
const table = await page.find('va-table-inner >>> .usa-table'); | ||
expect(table).not.toHaveClass('usa-table--striped'); | ||
}); | ||
|
||
it('has the USWDS striped class when striped is true', async () => { | ||
const page = await newE2EPage(); | ||
await page.setContent(makeTable({striped: 'true'})); | ||
const table = await page.find('va-table-inner >>> .usa-table'); | ||
expect(table).toHaveClass('usa-table--striped'); | ||
}); | ||
}); | ||
|
||
describe('sorted va-table ', () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some cleanup things along the way.