-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(sbb-clock): add visual spec (#2795)
- Loading branch information
Showing
3 changed files
with
84 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,41 @@ | ||
import { assert, expect } from '@open-wc/testing'; | ||
import { expect } from '@open-wc/testing'; | ||
import { html } from 'lit/static-html.js'; | ||
|
||
import { fixture, testA11yTreeSnapshot } from '../core/testing/private.js'; | ||
|
||
import { SbbClockElement } from './clock.js'; | ||
import type { SbbClockElement } from './clock.js'; | ||
import './clock.js'; | ||
|
||
describe(`sbb-clock`, () => { | ||
let element: SbbClockElement; | ||
|
||
it('renders', async () => { | ||
element = await fixture(html`<sbb-clock></sbb-clock>`); | ||
assert.instanceOf(element, SbbClockElement); | ||
describe('renders', () => { | ||
beforeEach(async () => { | ||
element = await fixture(html`<sbb-clock></sbb-clock>`); | ||
}); | ||
|
||
expect(element).dom.to.be.equal(`<sbb-clock></sbb-clock>`); | ||
it('DOM', async () => { | ||
await expect(element).dom.to.be.equalSnapshot(); | ||
}); | ||
|
||
await expect(element).shadowDom.to.be.equalSnapshot(); | ||
it('Shadow DOM', async () => { | ||
await expect(element).shadowDom.to.be.equalSnapshot(); | ||
}); | ||
|
||
testA11yTreeSnapshot(); | ||
}); | ||
|
||
it('renders with a fixed time', async () => { | ||
element = await fixture(html`<sbb-clock now="12:30:00"></sbb-clock>`); | ||
assert.instanceOf(element, SbbClockElement); | ||
describe('renders with fixed time', () => { | ||
beforeEach(async () => { | ||
element = await fixture(html`<sbb-clock now="12:30:00"></sbb-clock>`); | ||
}); | ||
|
||
expect(element).to.have.attribute('data-initialized'); | ||
it('DOM', async () => { | ||
await expect(element).dom.to.be.equalSnapshot(); | ||
}); | ||
|
||
await expect(element).shadowDom.to.be.equalSnapshot(); | ||
it('Shadow DOM', async () => { | ||
await expect(element).shadowDom.to.be.equalSnapshot(); | ||
}); | ||
}); | ||
|
||
testA11yTreeSnapshot(html`<sbb-clock></sbb-clock>`); | ||
}); |
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,27 @@ | ||
import { html } from 'lit'; | ||
|
||
import { describeViewports, visualDiffDefault } from '../core/testing/private.js'; | ||
|
||
import './clock.js'; | ||
|
||
describe(`sbb-clock`, () => { | ||
const timeCases = [ | ||
{ hours: '0', minutes: '0', seconds: '0' }, | ||
{ hours: '7', minutes: '32', seconds: '15' }, | ||
{ hours: '16', minutes: '15', seconds: '0' }, | ||
{ hours: '11', minutes: '60', seconds: '60' }, | ||
]; | ||
|
||
describeViewports({ viewports: ['medium'] }, () => { | ||
for (const time of timeCases) { | ||
const timeStamp = `${time.hours}:${time.minutes}:${time.seconds}`; | ||
|
||
it( | ||
`time=${timeStamp.replaceAll(':', '-')}`, | ||
visualDiffDefault.with(async (setup) => { | ||
await setup.withFixture(html`<sbb-clock now=${timeStamp}></sbb-clock>`); | ||
}), | ||
); | ||
} | ||
}); | ||
}); |