From cd40908258d4a5ad0dab91149c5be6ab8b90dcbe Mon Sep 17 00:00:00 2001 From: Serhii Kulykov Date: Mon, 7 Mar 2022 12:01:02 +0200 Subject: [PATCH] test: add snapshot tests for combo-box (#3522) --- packages/combo-box/test/basic.test.js | 5 - .../dom/__snapshots__/combo-box.test.snap.js | 394 ++++++++++++++++++ packages/combo-box/test/dom/combo-box.test.js | 77 ++++ 3 files changed, 471 insertions(+), 5 deletions(-) create mode 100644 packages/combo-box/test/dom/__snapshots__/combo-box.test.snap.js create mode 100644 packages/combo-box/test/dom/combo-box.test.js diff --git a/packages/combo-box/test/basic.test.js b/packages/combo-box/test/basic.test.js index b5af550631..155bab28d3 100644 --- a/packages/combo-box/test/basic.test.js +++ b/packages/combo-box/test/basic.test.js @@ -502,11 +502,6 @@ describe('theme attribute', () => { comboBox = fixtureSync(''); }); - it('should propagate theme attribute to input container', () => { - const inputField = comboBox.shadowRoot.querySelector('[part="input-field"]'); - expect(inputField.getAttribute('theme')).to.equal('foo'); - }); - it('should propagate theme attribute to overlay', () => { expect(comboBox.$.dropdown.$.overlay.getAttribute('theme')).to.equal('foo'); }); diff --git a/packages/combo-box/test/dom/__snapshots__/combo-box.test.snap.js b/packages/combo-box/test/dom/__snapshots__/combo-box.test.snap.js new file mode 100644 index 0000000000..2fb575d7f9 --- /dev/null +++ b/packages/combo-box/test/dom/__snapshots__/combo-box.test.snap.js @@ -0,0 +1,394 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["vaadin-combo-box host placeholder"] = +` + + + + +`; +/* end snapshot vaadin-combo-box host placeholder */ + +snapshots["vaadin-combo-box host pattern"] = +` + + + + +`; +/* end snapshot vaadin-combo-box host pattern */ + +snapshots["vaadin-combo-box shadow default"] = +`
+
+ + + +
+ + + + + + + + +
+ + +
+
+ + +
+
+ + +`; +/* end snapshot vaadin-combo-box shadow default */ + +snapshots["vaadin-combo-box shadow disabled"] = +`
+
+ + + +
+ + + + + + + + +
+ + +
+
+ + +
+
+ + +`; +/* end snapshot vaadin-combo-box shadow disabled */ + +snapshots["vaadin-combo-box shadow readonly"] = +`
+
+ + + +
+ + + + + + + + +
+ + +
+
+ + +
+
+ + +`; +/* end snapshot vaadin-combo-box shadow readonly */ + +snapshots["vaadin-combo-box shadow invalid"] = +`
+
+ + + +
+ + + + + + + + +
+ + +
+
+ + +
+
+ + +`; +/* end snapshot vaadin-combo-box shadow invalid */ + +snapshots["vaadin-combo-box shadow theme"] = +`
+
+ + + +
+ + + + + + + + +
+ + +
+
+ + +
+
+ + +`; +/* end snapshot vaadin-combo-box shadow theme */ + +snapshots["vaadin-combo-box slots default"] = +` + + +`; +/* end snapshot vaadin-combo-box slots default */ + +snapshots["vaadin-combo-box slots label"] = +` + + +`; +/* end snapshot vaadin-combo-box slots label */ + +snapshots["vaadin-combo-box slots helper"] = +` + + +
+ Helper +
+`; +/* end snapshot vaadin-combo-box slots helper */ + +snapshots["vaadin-combo-box slots error"] = +` + +
+ Error +
+`; +/* end snapshot vaadin-combo-box slots error */ + diff --git a/packages/combo-box/test/dom/combo-box.test.js b/packages/combo-box/test/dom/combo-box.test.js new file mode 100644 index 0000000000..fce6614a79 --- /dev/null +++ b/packages/combo-box/test/dom/combo-box.test.js @@ -0,0 +1,77 @@ +import { expect } from '@esm-bundle/chai'; +import { fixtureSync } from '@vaadin/testing-helpers'; +import '../../src/vaadin-combo-box.js'; + +describe('vaadin-combo-box', () => { + let comboBox; + + // Ignore generated attributes to prevent failures + // when running snapshot tests in a different order + const SNAPSHOT_CONFIG = { + ignoreAttributes: ['id', 'aria-describedby', 'aria-labelledby', 'for'] + }; + + beforeEach(() => { + comboBox = fixtureSync(''); + }); + + describe('host', () => { + it('placeholder', async () => { + comboBox.placeholder = 'Placeholder'; + await expect(comboBox).dom.to.equalSnapshot(SNAPSHOT_CONFIG); + }); + + it('pattern', async () => { + comboBox.pattern = '[0-9]*'; + await expect(comboBox).dom.to.equalSnapshot(SNAPSHOT_CONFIG); + }); + }); + + describe('shadow', () => { + it('default', async () => { + await expect(comboBox).shadowDom.to.equalSnapshot(); + }); + + it('disabled', async () => { + comboBox.disabled = true; + await expect(comboBox).shadowDom.to.equalSnapshot(); + }); + + it('readonly', async () => { + comboBox.readonly = true; + await expect(comboBox).shadowDom.to.equalSnapshot(); + }); + + it('invalid', async () => { + comboBox.invalid = true; + await expect(comboBox).shadowDom.to.equalSnapshot(); + }); + + it('theme', async () => { + comboBox.setAttribute('theme', 'align-right'); + await expect(comboBox).shadowDom.to.equalSnapshot(); + }); + }); + + describe('slots', () => { + it('default', async () => { + await expect(comboBox).lightDom.to.equalSnapshot(SNAPSHOT_CONFIG); + }); + + it('label', async () => { + comboBox.label = 'Label'; + await expect(comboBox).lightDom.to.equalSnapshot(SNAPSHOT_CONFIG); + }); + + it('helper', async () => { + comboBox.helperText = 'Helper'; + await expect(comboBox).lightDom.to.equalSnapshot(SNAPSHOT_CONFIG); + }); + + it('error', async () => { + comboBox.errorMessage = 'Error'; + comboBox.invalid = true; + await expect(comboBox).lightDom.to.equalSnapshot(SNAPSHOT_CONFIG); + }); + }); +});