From 2a01652bfa5d206583e5e411b97bc0aed55818a5 Mon Sep 17 00:00:00 2001 From: Jeri Peier Date: Mon, 8 Jan 2024 12:07:40 +0100 Subject: [PATCH] fix(sbb-icon): fix preserving space during loading (#2308) --- src/components/alert/alert/alert.spec.ts | 7 +++ .../breadcrumb-group/breadcrumb-group.spec.ts | 3 + src/components/button/button.spec.ts | 5 ++ src/components/calendar/calendar.spec.ts | 10 ++- .../checkbox/checkbox/checkbox.spec.ts | 9 ++- src/components/core/testing/test-setup.ts | 2 +- .../expansion-panel-header.spec.ts | 63 +++++++++++-------- .../file-selector/file-selector.spec.ts | 5 ++ .../form-field-clear/form-field-clear.spec.ts | 5 ++ .../form-field/form-field/form-field.spec.ts | 7 +++ .../header-action/header-action.spec.ts | 5 ++ src/components/icon/icon-base.ts | 6 +- src/components/icon/icon.spec.ts | 4 +- .../journey-header/journey-header.spec.ts | 9 ++- src/components/link/link.spec.ts | 9 ++- .../menu/menu-action/menu-action.spec.ts | 5 ++ .../notification/notification.spec.ts | 19 ++++-- src/components/slider/slider.spec.ts | 5 ++ src/components/status/status.spec.ts | 7 +++ .../tabs/tab-title/tab-title.spec.ts | 5 ++ src/components/tag/tag/tag.spec.ts | 7 +++ .../timetable-row/timetable-row.spec.ts | 1 - src/components/toast/toast.spec.ts | 11 ++-- .../toggle-check/toggle-check.spec.ts | 18 +++++- .../toggle-option/toggle-option.spec.ts | 10 ++- .../tooltip-trigger/tooltip-trigger.spec.ts | 15 +++-- 26 files changed, 192 insertions(+), 60 deletions(-) diff --git a/src/components/alert/alert/alert.spec.ts b/src/components/alert/alert/alert.spec.ts index 7f26f854f8..afe1675e51 100644 --- a/src/components/alert/alert/alert.spec.ts +++ b/src/components/alert/alert/alert.spec.ts @@ -1,7 +1,10 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; +import { waitForLitRender } from '../../core/testing'; + import type { SbbAlertElement } from './alert'; + import './alert'; describe('sbb-alert', () => { @@ -12,6 +15,8 @@ describe('sbb-alert', () => { html`Alert content`, ); + await waitForLitRender(element); + expect(element).dom.to.be.equal( ` @@ -68,6 +73,8 @@ describe('sbb-alert', () => { >`, ); + await waitForLitRender(element); + expect(element).dom.to.be.equal( ` diff --git a/src/components/breadcrumb/breadcrumb-group/breadcrumb-group.spec.ts b/src/components/breadcrumb/breadcrumb-group/breadcrumb-group.spec.ts index 57fca3fa3c..859548f7b0 100644 --- a/src/components/breadcrumb/breadcrumb-group/breadcrumb-group.spec.ts +++ b/src/components/breadcrumb/breadcrumb-group/breadcrumb-group.spec.ts @@ -3,6 +3,7 @@ import { html } from 'lit/static-html.js'; import '../breadcrumb'; import './breadcrumb-group'; +import { waitForLitRender } from '../../core/testing'; describe('sbb-breadcrumb-group', () => { it('renders', async () => { @@ -14,6 +15,8 @@ describe('sbb-breadcrumb-group', () => { `); + await waitForLitRender(root); + expect(root).dom.to.be.equal(` diff --git a/src/components/button/button.spec.ts b/src/components/button/button.spec.ts index a1f316ca42..0009f67858 100644 --- a/src/components/button/button.spec.ts +++ b/src/components/button/button.spec.ts @@ -1,5 +1,8 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; + +import { waitForLitRender } from '../core/testing'; + import '../form-field'; import './button'; @@ -53,6 +56,8 @@ describe('sbb-button', () => { `, ); + await waitForLitRender(root); + expect(root).dom.to.be.equal(` diff --git a/src/components/calendar/calendar.spec.ts b/src/components/calendar/calendar.spec.ts index 146519c1c6..167762b9cb 100644 --- a/src/components/calendar/calendar.spec.ts +++ b/src/components/calendar/calendar.spec.ts @@ -1,9 +1,11 @@ -import './calendar'; -import '../button'; - import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; +import { waitForLitRender } from '../core/testing'; + +import './calendar'; +import '../button'; + describe('sbb-calendar', () => { it('renders', async () => { const root = await fixture( @@ -13,6 +15,8 @@ describe('sbb-calendar', () => { >`, ); + await waitForLitRender(root); + expect(root).dom.to.be.equal( ``, ); diff --git a/src/components/checkbox/checkbox/checkbox.spec.ts b/src/components/checkbox/checkbox/checkbox.spec.ts index fd0612c33b..32223fbab3 100644 --- a/src/components/checkbox/checkbox/checkbox.spec.ts +++ b/src/components/checkbox/checkbox/checkbox.spec.ts @@ -1,7 +1,10 @@ -import './checkbox'; import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; +import { waitForLitRender } from '../../core/testing'; + +import './checkbox'; + describe('sbb-checkbox', () => { it('renders', async () => { const root = await fixture(html`Label`); @@ -12,6 +15,8 @@ describe('sbb-checkbox', () => { `); + await waitForLitRender(root); + expect(root).shadowDom.to.be.equal(` - @@ -39,15 +44,17 @@ describe('sbb-expansion-panel-header', () => { html`Header`, ); + await waitForLitRender(root); + expect(root).dom.to.be.equal( ` - Header @@ -71,11 +78,11 @@ describe('sbb-expansion-panel-header', () => { - @@ -91,14 +98,16 @@ describe('sbb-expansion-panel-header', () => { `); + await waitForLitRender(root); + expect(root).dom.to.be.equal( ` - Header @@ -115,11 +124,11 @@ describe('sbb-expansion-panel-header', () => { - diff --git a/src/components/file-selector/file-selector.spec.ts b/src/components/file-selector/file-selector.spec.ts index 119a843653..375867d4db 100644 --- a/src/components/file-selector/file-selector.spec.ts +++ b/src/components/file-selector/file-selector.spec.ts @@ -1,5 +1,8 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; + +import { waitForLitRender } from '../core/testing'; + import './file-selector'; describe('sbb-file-selector', () => { @@ -28,6 +31,8 @@ describe('sbb-file-selector', () => { it('renders with dropzone area', async () => { const root = await fixture(html``); + await waitForLitRender(root); + expect(root).dom.to.be.equal(` diff --git a/src/components/form-field/form-field-clear/form-field-clear.spec.ts b/src/components/form-field/form-field-clear/form-field-clear.spec.ts index db7623b5ef..273d9e4274 100644 --- a/src/components/form-field/form-field-clear/form-field-clear.spec.ts +++ b/src/components/form-field/form-field-clear/form-field-clear.spec.ts @@ -1,5 +1,8 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; + +import { waitForLitRender } from '../../core/testing'; + import './form-field-clear'; import '../form-field'; @@ -11,6 +14,8 @@ describe('sbb-form-field-clear', () => { `); + await waitForLitRender(formField); + const formFieldClear = formField.querySelector('sbb-form-field-clear'); expect(formField).dom.to.be.equal(` diff --git a/src/components/form-field/form-field/form-field.spec.ts b/src/components/form-field/form-field/form-field.spec.ts index e774c37310..6bde2cfbf6 100644 --- a/src/components/form-field/form-field/form-field.spec.ts +++ b/src/components/form-field/form-field/form-field.spec.ts @@ -1,5 +1,8 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; + +import { waitForLitRender } from '../../core/testing'; + import './form-field'; describe('sbb-form-field', () => { @@ -197,6 +200,8 @@ describe('sbb-form-field', () => { `); + await waitForLitRender(root); + expect(root).dom.to.be.equal(` @@ -44,6 +48,8 @@ describe('sbb-toggle-check', () => { Check it `); + await waitForLitRender(root); + expect(root).dom.to.be.equal(` Check it @@ -80,6 +86,8 @@ describe('sbb-toggle-check', () => { it('renders toggle in checked state', async () => { const root = await fixture(html``); + await waitForLitRender(root); + expect(root).dom.to.be.equal( ` @@ -117,6 +125,8 @@ describe('sbb-toggle-check', () => { it('renders toggle in disabled state', async () => { const root = await fixture(html``); + await waitForLitRender(root); + expect(root).dom.to.be.equal(` @@ -152,10 +162,12 @@ describe('sbb-toggle-check', () => { it('renders toggle in disabled and checked state', async () => { const root = await fixture(html``); + await waitForLitRender(root); + expect(root).dom.to.be.equal( ` - + `, ); diff --git a/src/components/toggle/toggle-option/toggle-option.spec.ts b/src/components/toggle/toggle-option/toggle-option.spec.ts index 2c9b2947b4..aca3e7319e 100644 --- a/src/components/toggle/toggle-option/toggle-option.spec.ts +++ b/src/components/toggle/toggle-option/toggle-option.spec.ts @@ -1,9 +1,11 @@ -import './toggle-option'; -import '../../icon'; - import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; +import { waitForLitRender } from '../../core/testing'; + +import './toggle-option'; +import '../../icon'; + describe('sbb-toggle-option', () => { it('renders', async () => { const root = await fixture( @@ -34,6 +36,8 @@ describe('sbb-toggle-option', () => { html``, ); + await waitForLitRender(root); + expect(root).dom.to.be.equal( ` { it('renders', async () => { const root = await fixture(html``); + await waitForLitRender(root); + expect(root).dom.to.be.equal( ``, ); expect(root).shadowDom.to.be.equal( ` -