Skip to content
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

test: re-organize and add more snapshot tests #4054

Merged
merged 9 commits into from
Jun 17, 2022
252 changes: 132 additions & 120 deletions packages/combo-box/test/dom/__snapshots__/combo-box.test.snap.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
/* @web/test-runner snapshot v1 */
export const snapshots = {};

snapshots["vaadin-combo-box host default"] =
`<vaadin-combo-box>
<label
for="input-vaadin-combo-box-4"
id="label-vaadin-combo-box-0"
slot="label"
>
</label>
<div
hidden=""
id="error-message-vaadin-combo-box-2"
slot="error-message"
>
</div>
<input
aria-autocomplete="list"
aria-expanded="false"
autocapitalize="off"
autocomplete="off"
autocorrect="off"
id="input-vaadin-combo-box-4"
role="combobox"
slot="input"
spellcheck="false"
>
</vaadin-combo-box>
`;
/* end snapshot vaadin-combo-box host default */

snapshots["vaadin-combo-box host placeholder"] =
`<vaadin-combo-box placeholder="Placeholder">
<label
Expand Down Expand Up @@ -61,6 +90,109 @@ snapshots["vaadin-combo-box host pattern"] =
`;
/* end snapshot vaadin-combo-box host pattern */

snapshots["vaadin-combo-box host label"] =
`<vaadin-combo-box has-label="">
<label
for="input-vaadin-combo-box-4"
id="label-vaadin-combo-box-0"
slot="label"
>
Label
</label>
<div
hidden=""
id="error-message-vaadin-combo-box-2"
slot="error-message"
>
</div>
<input
aria-autocomplete="list"
aria-expanded="false"
aria-labelledby="label-vaadin-combo-box-0"
autocapitalize="off"
autocomplete="off"
autocorrect="off"
id="input-vaadin-combo-box-4"
role="combobox"
slot="input"
spellcheck="false"
>
</vaadin-combo-box>
`;
/* end snapshot vaadin-combo-box host label */

snapshots["vaadin-combo-box host helper"] =
`<vaadin-combo-box has-helper="">
<label
for="input-vaadin-combo-box-4"
id="label-vaadin-combo-box-0"
slot="label"
>
</label>
<div
hidden=""
id="error-message-vaadin-combo-box-2"
slot="error-message"
>
</div>
<input
aria-autocomplete="list"
aria-describedby="helper-vaadin-combo-box-1"
aria-expanded="false"
autocapitalize="off"
autocomplete="off"
autocorrect="off"
id="input-vaadin-combo-box-4"
role="combobox"
slot="input"
spellcheck="false"
>
<div
id="helper-vaadin-combo-box-1"
slot="helper"
>
Helper
</div>
</vaadin-combo-box>
`;
/* end snapshot vaadin-combo-box host helper */

snapshots["vaadin-combo-box host error"] =
`<vaadin-combo-box
has-error-message=""
invalid=""
>
<label
for="input-vaadin-combo-box-4"
id="label-vaadin-combo-box-0"
slot="label"
>
</label>
<div
id="error-message-vaadin-combo-box-2"
role="alert"
slot="error-message"
>
Error
</div>
<input
aria-autocomplete="list"
aria-describedby="error-message-vaadin-combo-box-2"
aria-expanded="false"
aria-invalid="true"
autocapitalize="off"
autocomplete="off"
autocorrect="off"
id="input-vaadin-combo-box-4"
invalid=""
role="combobox"
slot="input"
spellcheck="false"
>
</vaadin-combo-box>
`;
/* end snapshot vaadin-combo-box host error */

snapshots["vaadin-combo-box shadow default"] =
`<div class="vaadin-combo-box-container">
<div part="label">
Expand Down Expand Up @@ -364,123 +496,3 @@ snapshots["vaadin-combo-box shadow theme"] =
`;
/* end snapshot vaadin-combo-box shadow theme */

snapshots["vaadin-combo-box slots default"] =
`<label
for="input-vaadin-combo-box-4"
id="label-vaadin-combo-box-0"
slot="label"
>
</label>
<div
hidden=""
id="error-message-vaadin-combo-box-2"
slot="error-message"
>
</div>
<input
aria-autocomplete="list"
aria-expanded="false"
autocapitalize="off"
autocomplete="off"
autocorrect="off"
id="input-vaadin-combo-box-4"
role="combobox"
slot="input"
spellcheck="false"
>
`;
/* end snapshot vaadin-combo-box slots default */

snapshots["vaadin-combo-box slots label"] =
`<label
for="input-vaadin-combo-box-4"
id="label-vaadin-combo-box-0"
slot="label"
>
Label
</label>
<div
hidden=""
id="error-message-vaadin-combo-box-2"
slot="error-message"
>
</div>
<input
aria-autocomplete="list"
aria-expanded="false"
aria-labelledby="label-vaadin-combo-box-0"
autocapitalize="off"
autocomplete="off"
autocorrect="off"
id="input-vaadin-combo-box-4"
role="combobox"
slot="input"
spellcheck="false"
>
`;
/* end snapshot vaadin-combo-box slots label */

snapshots["vaadin-combo-box slots helper"] =
`<label
for="input-vaadin-combo-box-4"
id="label-vaadin-combo-box-0"
slot="label"
>
</label>
<div
hidden=""
id="error-message-vaadin-combo-box-2"
slot="error-message"
>
</div>
<input
aria-autocomplete="list"
aria-describedby="helper-vaadin-combo-box-1"
aria-expanded="false"
autocapitalize="off"
autocomplete="off"
autocorrect="off"
id="input-vaadin-combo-box-4"
role="combobox"
slot="input"
spellcheck="false"
>
<div
id="helper-vaadin-combo-box-1"
slot="helper"
>
Helper
</div>
`;
/* end snapshot vaadin-combo-box slots helper */

snapshots["vaadin-combo-box slots error"] =
`<label
for="input-vaadin-combo-box-4"
id="label-vaadin-combo-box-0"
slot="label"
>
</label>
<div
id="error-message-vaadin-combo-box-2"
role="alert"
slot="error-message"
>
Error
</div>
<input
aria-autocomplete="list"
aria-expanded="false"
aria-invalid="true"
autocapitalize="off"
autocomplete="off"
autocorrect="off"
id="input-vaadin-combo-box-4"
invalid=""
role="combobox"
slot="input"
spellcheck="false"
>
`;
/* end snapshot vaadin-combo-box slots error */

45 changes: 22 additions & 23 deletions packages/combo-box/test/dom/combo-box.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from '@esm-bundle/chai';
import { fixtureSync } from '@vaadin/testing-helpers';
import { aTimeout, fixtureSync } from '@vaadin/testing-helpers';
import '../../src/vaadin-combo-box.js';
import { resetUniqueId } from '@vaadin/component-base/src/unique-id-utils.js';

Expand All @@ -12,6 +12,10 @@ describe('vaadin-combo-box', () => {
});

describe('host', () => {
it('default', async () => {
await expect(comboBox).dom.to.equalSnapshot();
});

it('placeholder', async () => {
comboBox.placeholder = 'Placeholder';
await expect(comboBox).dom.to.equalSnapshot();
Expand All @@ -21,6 +25,23 @@ describe('vaadin-combo-box', () => {
comboBox.pattern = '[0-9]*';
await expect(comboBox).dom.to.equalSnapshot();
});

it('label', async () => {
comboBox.label = 'Label';
await expect(comboBox).dom.to.equalSnapshot();
});

it('helper', async () => {
comboBox.helperText = 'Helper';
await expect(comboBox).dom.to.equalSnapshot();
});

it('error', async () => {
comboBox.errorMessage = 'Error';
comboBox.invalid = true;
await aTimeout(0);
await expect(comboBox).dom.to.equalSnapshot();
});
});

describe('shadow', () => {
Expand Down Expand Up @@ -48,26 +69,4 @@ describe('vaadin-combo-box', () => {
await expect(comboBox).shadowDom.to.equalSnapshot();
});
});

describe('slots', () => {
it('default', async () => {
await expect(comboBox).lightDom.to.equalSnapshot();
});

it('label', async () => {
comboBox.label = 'Label';
await expect(comboBox).lightDom.to.equalSnapshot();
});

it('helper', async () => {
comboBox.helperText = 'Helper';
await expect(comboBox).lightDom.to.equalSnapshot();
});

it('error', async () => {
comboBox.errorMessage = 'Error';
comboBox.invalid = true;
await expect(comboBox).lightDom.to.equalSnapshot();
});
});
});
Loading