diff --git a/src/components/alert/alert.test.ts b/src/components/alert/alert.test.ts index 409ddc2fe6..479344406c 100644 --- a/src/components/alert/alert.test.ts +++ b/src/components/alert/alert.test.ts @@ -6,21 +6,21 @@ import type SlAlert from './alert'; describe('', () => { it('should be visible with the open attribute', async () => { - const el = await fixture(html` I am an alert `); + const el = await fixture(html` I am an alert `); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; expect(base.hidden).to.be.false; }); it('should not be visible without the open attribute', async () => { - const el = await fixture(html` I am an alert `); + const el = await fixture(html` I am an alert `); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; expect(base.hidden).to.be.true; }); it('should emit sl-show and sl-after-show when calling show()', async () => { - const el = (await fixture(html` I am an alert `)) as SlAlert; + const el = await fixture(html` I am an alert `); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; const showHandler = sinon.spy(); const afterShowHandler = sinon.spy(); @@ -38,7 +38,7 @@ describe('', () => { }); it('should emit sl-hide and sl-after-hide when calling hide()', async () => { - const el = (await fixture(html` I am an alert `)) as SlAlert; + const el = await fixture(html` I am an alert `); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; const hideHandler = sinon.spy(); const afterHideHandler = sinon.spy(); @@ -56,7 +56,7 @@ describe('', () => { }); it('should emit sl-show and sl-after-show when setting open = true', async () => { - const el = (await fixture(html` I am an alert `)) as SlAlert; + const el = await fixture(html` I am an alert `); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; const showHandler = sinon.spy(); const afterShowHandler = sinon.spy(); @@ -74,7 +74,7 @@ describe('', () => { }); it('should emit sl-hide and sl-after-hide when setting open = false', async () => { - const el = (await fixture(html` I am an alert `)) as SlAlert; + const el = await fixture(html` I am an alert `); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; const hideHandler = sinon.spy(); const afterHideHandler = sinon.spy(); diff --git a/src/components/checkbox/checkbox.test.ts b/src/components/checkbox/checkbox.test.ts index dcc8d0876b..85d339ce5b 100644 --- a/src/components/checkbox/checkbox.test.ts +++ b/src/components/checkbox/checkbox.test.ts @@ -1,44 +1,44 @@ import { expect, fixture, html, oneEvent } from '@open-wc/testing'; -import { sendKeys } from '@web/test-runner-commands' +import { sendKeys } from '@web/test-runner-commands'; import '../../../dist/shoelace.js'; import type SlCheckbox from './checkbox'; describe('', () => { it('should be disabled with the disabled attribute', async () => { - const el = await fixture(html` `); + const el = await fixture(html` `); const checkbox = el.shadowRoot?.querySelector('input'); expect(checkbox.disabled).to.be.true; }); it('should be valid by default', async () => { - const el = (await fixture(html` `)) + const el = await fixture(html` `); expect(el.invalid).to.be.false; }); it('should fire sl-change when clicked', async () => { - const el = (await fixture(html` `)) + const el = await fixture(html` `); setTimeout(() => el.shadowRoot?.querySelector('input').click()); - const event = await oneEvent(el, 'sl-change') + const event = await oneEvent(el, 'sl-change'); expect(event.target).to.equal(el); expect(el.checked).to.be.true; }); it('should fire sl-change when toggled via keyboard', async () => { - const el = (await fixture(html` `)) + const el = await fixture(html` `); const input = el.shadowRoot?.querySelector('input'); input.focus(); setTimeout(() => sendKeys({ press: ' ' })); - const event = await oneEvent(el, 'sl-change') + const event = await oneEvent(el, 'sl-change'); expect(event.target).to.equal(el); expect(el.checked).to.be.true; }); it('should not fire sl-change when checked is set by javascript', async () => { - const el = (await fixture(html` `)) - el.addEventListener('sl-change', () => expect.fail('event fired')) + const el = await fixture(html` `); + el.addEventListener('sl-change', () => expect.fail('event fired')); el.checked = true; await el.updateComplete; el.checked = false; diff --git a/src/components/color-picker/color-picker.test.ts b/src/components/color-picker/color-picker.test.ts index ef67aff559..0c6e13b718 100644 --- a/src/components/color-picker/color-picker.test.ts +++ b/src/components/color-picker/color-picker.test.ts @@ -6,7 +6,7 @@ import type SlColorPicker from './color-picker'; describe('', () => { it('should emit change and show correct color when the value changes', async () => { - const el = (await fixture(html` `)) as SlColorPicker; + const el = await fixture(html` `); const trigger = el.shadowRoot.querySelector('[part="trigger"]') as HTMLElement; const changeHandler = sinon.spy(); const color = 'rgb(255, 204, 0)'; @@ -21,21 +21,21 @@ describe('', () => { }); it('should render in a dropdown', async () => { - const el = (await fixture(html` `)) as SlColorPicker; + const el = await fixture(html` `); const dropdown = el.shadowRoot.querySelector('sl-dropdown'); expect(dropdown).to.exist; }); it('should not render in a dropdown when inline is enabled', async () => { - const el = (await fixture(html` `)) as SlColorPicker; + const el = await fixture(html` `); const dropdown = el.shadowRoot.querySelector('sl-dropdown'); expect(dropdown).to.not.exist; }); it('should show opacity slider when opacity is enabled', async () => { - const el = (await fixture(html` `)) as SlColorPicker; + const el = await fixture(html` `); const opacitySlider = el.shadowRoot.querySelector('[part*="opacity-slider"]') as HTMLElement; expect(opacitySlider).to.exist; diff --git a/src/components/details/details.test.ts b/src/components/details/details.test.ts index 125cc3f60f..cb75deeeb2 100644 --- a/src/components/details/details.test.ts +++ b/src/components/details/details.test.ts @@ -6,7 +6,7 @@ import type SlDetails from './details'; describe('', () => { it('should be visible with the open attribute', async () => { - const el = await fixture(html` + const el = await fixture(html` Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo @@ -19,7 +19,7 @@ describe('', () => { }); it('should not be visible without the open attribute', async () => { - const el = await fixture(html` + const el = await fixture(html` Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo @@ -32,13 +32,13 @@ describe('', () => { }); it('should emit sl-show and sl-after-show when calling show()', async () => { - const el = (await fixture(html` + const el = await fixture(html` Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - `)) as SlDetails; + `); const body = el.shadowRoot?.querySelector('.details__body') as HTMLElement; const showHandler = sinon.spy(); const afterShowHandler = sinon.spy(); @@ -56,13 +56,13 @@ describe('', () => { }); it('should emit sl-hide and sl-after-hide when calling hide()', async () => { - const el = (await fixture(html` + const el = await fixture(html` Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - `)) as SlDetails; + `); const body = el.shadowRoot?.querySelector('.details__body') as HTMLElement; const hideHandler = sinon.spy(); const afterHideHandler = sinon.spy(); @@ -80,13 +80,13 @@ describe('', () => { }); it('should emit sl-show and sl-after-show when setting open = true', async () => { - const el = (await fixture(html` + const el = await fixture(html` Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - `)) as SlDetails; + `); const body = el.shadowRoot?.querySelector('.details__body') as HTMLElement; const showHandler = sinon.spy(); const afterShowHandler = sinon.spy(); @@ -104,13 +104,13 @@ describe('', () => { }); it('should emit sl-hide and sl-after-hide when setting open = false', async () => { - const el = (await fixture(html` + const el = await fixture(html` Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - `)) as SlDetails; + `); const body = el.shadowRoot?.querySelector('.details__body') as HTMLElement; const hideHandler = sinon.spy(); const afterHideHandler = sinon.spy(); @@ -128,7 +128,7 @@ describe('', () => { }); it('should be the correct size after opening more than one instance', async () => { - const el = await fixture(html` + const el = await fixture(html`
diff --git a/src/components/dialog/dialog.test.ts b/src/components/dialog/dialog.test.ts index 9fa9e0488f..e5b9995bdf 100644 --- a/src/components/dialog/dialog.test.ts +++ b/src/components/dialog/dialog.test.ts @@ -6,7 +6,7 @@ import type SlDialog from './dialog'; describe('', () => { it('should be visible with the open attribute', async () => { - const el = await fixture(html` + const el = await fixture(html` Lorem ipsum dolor sit amet, consectetur adipiscing elit. `); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; @@ -15,16 +15,18 @@ describe('', () => { }); it('should not be visible without the open attribute', async () => { - const el = await fixture(html` Lorem ipsum dolor sit amet, consectetur adipiscing elit. `); + const el = await fixture( + html` Lorem ipsum dolor sit amet, consectetur adipiscing elit. ` + ); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; expect(base.hidden).to.be.true; }); it('should emit sl-show and sl-after-show when calling show()', async () => { - const el = (await fixture(html` + const el = await fixture(html` Lorem ipsum dolor sit amet, consectetur adipiscing elit. - `)) as SlDialog; + `); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; const showHandler = sinon.spy(); const afterShowHandler = sinon.spy(); @@ -42,9 +44,9 @@ describe('', () => { }); it('should emit sl-hide and sl-after-hide when calling hide()', async () => { - const el = (await fixture(html` + const el = await fixture(html` Lorem ipsum dolor sit amet, consectetur adipiscing elit. - `)) as SlDialog; + `); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; const hideHandler = sinon.spy(); const afterHideHandler = sinon.spy(); @@ -62,9 +64,9 @@ describe('', () => { }); it('should emit sl-show and sl-after-show when setting open = true', async () => { - const el = (await fixture(html` + const el = await fixture(html` Lorem ipsum dolor sit amet, consectetur adipiscing elit. - `)) as SlDialog; + `); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; const showHandler = sinon.spy(); const afterShowHandler = sinon.spy(); @@ -82,9 +84,9 @@ describe('', () => { }); it('should emit sl-hide and sl-after-hide when setting open = false', async () => { - const el = (await fixture(html` + const el = await fixture(html` Lorem ipsum dolor sit amet, consectetur adipiscing elit. - `)) as SlDialog; + `); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; const hideHandler = sinon.spy(); const afterHideHandler = sinon.spy(); @@ -102,9 +104,9 @@ describe('', () => { }); it('should not close when sl-request-close is prevented', async () => { - const el = (await fixture(html` + const el = await fixture(html` Lorem ipsum dolor sit amet, consectetur adipiscing elit. - `)) as SlDialog; + `); const overlay = el.shadowRoot?.querySelector('[part="overlay"]') as HTMLElement; el.addEventListener('sl-request-close', event => event.preventDefault()); @@ -114,7 +116,7 @@ describe('', () => { }); it('should allow initial focus to be set', async () => { - const el = (await fixture(html` `)) as SlDialog; + const el = await fixture(html` `); const input = el.querySelector('input'); const initialFocusHandler = sinon.spy(event => { event.preventDefault(); diff --git a/src/components/drawer/drawer.test.ts b/src/components/drawer/drawer.test.ts index 9ad4cc8dd0..7e9640007b 100644 --- a/src/components/drawer/drawer.test.ts +++ b/src/components/drawer/drawer.test.ts @@ -6,7 +6,7 @@ import type SlDrawer from './drawer'; describe('', () => { it('should be visible with the open attribute', async () => { - const el = await fixture(html` + const el = await fixture(html` Lorem ipsum dolor sit amet, consectetur adipiscing elit. `); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; @@ -15,16 +15,18 @@ describe('', () => { }); it('should not be visible without the open attribute', async () => { - const el = await fixture(html` Lorem ipsum dolor sit amet, consectetur adipiscing elit. `); + const el = await fixture( + html` Lorem ipsum dolor sit amet, consectetur adipiscing elit. ` + ); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; expect(base.hidden).to.be.true; }); it('should emit sl-show and sl-after-show when calling show()', async () => { - const el = (await fixture(html` + const el = await fixture(html` Lorem ipsum dolor sit amet, consectetur adipiscing elit. - `)) as SlDrawer; + `); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; const showHandler = sinon.spy(); const afterShowHandler = sinon.spy(); @@ -42,9 +44,9 @@ describe('', () => { }); it('should emit sl-hide and sl-after-hide when calling hide()', async () => { - const el = (await fixture(html` + const el = await fixture(html` Lorem ipsum dolor sit amet, consectetur adipiscing elit. - `)) as SlDrawer; + `); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; const hideHandler = sinon.spy(); const afterHideHandler = sinon.spy(); @@ -62,9 +64,9 @@ describe('', () => { }); it('should emit sl-show and sl-after-show when setting open = true', async () => { - const el = (await fixture(html` + const el = await fixture(html` Lorem ipsum dolor sit amet, consectetur adipiscing elit. - `)) as SlDrawer; + `); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; const showHandler = sinon.spy(); const afterShowHandler = sinon.spy(); @@ -82,9 +84,9 @@ describe('', () => { }); it('should emit sl-hide and sl-after-hide when setting open = false', async () => { - const el = (await fixture(html` + const el = await fixture(html` Lorem ipsum dolor sit amet, consectetur adipiscing elit. - `)) as SlDrawer; + `); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; const hideHandler = sinon.spy(); const afterHideHandler = sinon.spy(); @@ -102,9 +104,9 @@ describe('', () => { }); it('should not close when sl-request-close is prevented', async () => { - const el = (await fixture(html` + const el = await fixture(html` Lorem ipsum dolor sit amet, consectetur adipiscing elit. - `)) as SlDrawer; + `); const overlay = el.shadowRoot?.querySelector('[part="overlay"]') as HTMLElement; el.addEventListener('sl-request-close', event => event.preventDefault()); @@ -114,7 +116,7 @@ describe('', () => { }); it('should allow initial focus to be set', async () => { - const el = (await fixture(html` `)) as SlDrawer; + const el = await fixture(html` `); const input = el.querySelector('input'); const initialFocusHandler = sinon.spy(event => { event.preventDefault(); diff --git a/src/components/dropdown/dropdown.test.ts b/src/components/dropdown/dropdown.test.ts index 032cabaef4..428d942d42 100644 --- a/src/components/dropdown/dropdown.test.ts +++ b/src/components/dropdown/dropdown.test.ts @@ -6,7 +6,7 @@ import type SlDropdown from './dropdown'; describe('', () => { it('should be visible with the open attribute', async () => { - const el = await fixture(html` + const el = await fixture(html` Toggle @@ -22,7 +22,7 @@ describe('', () => { }); it('should not be visible without the open attribute', async () => { - const el = await fixture(html` + const el = await fixture(html` Toggle @@ -38,7 +38,7 @@ describe('', () => { }); it('should emit sl-show and sl-after-show when calling show()', async () => { - const el = (await fixture(html` + const el = await fixture(html` Toggle @@ -47,7 +47,7 @@ describe('', () => { Item 3 - `)) as SlDropdown; + `); const panel = el.shadowRoot?.querySelector('[part="panel"]') as HTMLElement; const showHandler = sinon.spy(); const afterShowHandler = sinon.spy(); @@ -65,7 +65,7 @@ describe('', () => { }); it('should emit sl-hide and sl-after-hide when calling hide()', async () => { - const el = (await fixture(html` + const el = await fixture(html` Toggle @@ -74,7 +74,7 @@ describe('', () => { Item 3 - `)) as SlDropdown; + `); const panel = el.shadowRoot?.querySelector('[part="panel"]') as HTMLElement; const hideHandler = sinon.spy(); const afterHideHandler = sinon.spy(); @@ -92,7 +92,7 @@ describe('', () => { }); it('should emit sl-show and sl-after-show when setting open = true', async () => { - const el = (await fixture(html` + const el = await fixture(html` Toggle @@ -101,7 +101,7 @@ describe('', () => { Item 3 - `)) as SlDropdown; + `); const panel = el.shadowRoot?.querySelector('[part="panel"]') as HTMLElement; const showHandler = sinon.spy(); const afterShowHandler = sinon.spy(); @@ -119,7 +119,7 @@ describe('', () => { }); it('should emit sl-hide and sl-after-hide when setting open = false', async () => { - const el = (await fixture(html` + const el = await fixture(html` Toggle @@ -128,7 +128,7 @@ describe('', () => { Item 3 - `)) as SlDropdown; + `); const panel = el.shadowRoot?.querySelector('[part="panel"]') as HTMLElement; const hideHandler = sinon.spy(); const afterHideHandler = sinon.spy(); diff --git a/src/components/include/include.test.ts b/src/components/include/include.test.ts index cd91d8ec73..b3d371904e 100644 --- a/src/components/include/include.test.ts +++ b/src/components/include/include.test.ts @@ -6,7 +6,9 @@ import type SlInclude from './include'; describe('', () => { it('should load content and emit sl-load', async () => { - const el = await fixture(html` `); + const el = await fixture( + html` ` + ); const loadHandler = sinon.spy(); el.addEventListener('sl-load', loadHandler); @@ -17,7 +19,7 @@ describe('', () => { }); it('should emit sl-error when content cannot be loaded', async () => { - const el = await fixture(html` `); + const el = await fixture(html` `); const loadHandler = sinon.spy(); el.addEventListener('sl-error', loadHandler); diff --git a/src/components/input/input.test.ts b/src/components/input/input.test.ts index 40835bf5ac..fb27016a4b 100644 --- a/src/components/input/input.test.ts +++ b/src/components/input/input.test.ts @@ -6,26 +6,26 @@ import type SlInput from './input'; describe('', () => { it('should be disabled with the disabled attribute', async () => { - const el = await fixture(html` `); + const el = await fixture(html` `); const input = el.shadowRoot?.querySelector('[part="input"]') as HTMLInputElement; expect(input.disabled).to.be.true; }); it('should be valid by default', async () => { - const el = (await fixture(html` `)) as SlInput; + const el = await fixture(html` `); expect(el.invalid).to.be.false; }); it('should be invalid when required and empty', async () => { - const el = (await fixture(html` `)) as SlInput; + const el = await fixture(html` `); expect(el.invalid).to.be.true; }); it('should be invalid when required and after removing disabled ', async () => { - const el = (await fixture(html` `)) as SlInput; + const el = await fixture(html` `); el.disabled = false; await el.updateComplete; diff --git a/src/components/radio/radio.test.ts b/src/components/radio/radio.test.ts index dccfe10677..bf90ec5311 100644 --- a/src/components/radio/radio.test.ts +++ b/src/components/radio/radio.test.ts @@ -1,44 +1,44 @@ import { expect, fixture, html, oneEvent } from '@open-wc/testing'; -import { sendKeys } from '@web/test-runner-commands' +import { sendKeys } from '@web/test-runner-commands'; import '../../../dist/shoelace.js'; import type SlRadio from './radio'; describe('', () => { it('should be disabled with the disabled attribute', async () => { - const el = await fixture(html` `); + const el = await fixture(html` `); const radio = el.shadowRoot?.querySelector('input'); expect(radio.disabled).to.be.true; }); it('should be valid by default', async () => { - const el = (await fixture(html` `)) + const el = await fixture(html` `); expect(el.invalid).to.be.false; }); it('should fire sl-change when clicked', async () => { - const el = (await fixture(html` `)) + const el = await fixture(html` `); setTimeout(() => el.shadowRoot?.querySelector('input').click()); - const event = await oneEvent(el, 'sl-change') + const event = await oneEvent(el, 'sl-change'); expect(event.target).to.equal(el); expect(el.checked).to.be.true; }); it('should fire sl-change when toggled via keyboard', async () => { - const el = (await fixture(html` `)) + const el = await fixture(html` `); const input = el.shadowRoot?.querySelector('input'); input.focus(); setTimeout(() => sendKeys({ press: ' ' })); - const event = await oneEvent(el, 'sl-change') + const event = await oneEvent(el, 'sl-change'); expect(event.target).to.equal(el); expect(el.checked).to.be.true; }); it('should not fire sl-change when checked is set by javascript', async () => { - const el = (await fixture(html` `)) - el.addEventListener('sl-change', () => expect.fail('event fired')) + const el = await fixture(html` `); + el.addEventListener('sl-change', () => expect.fail('event fired')); el.checked = true; await el.updateComplete; el.checked = false; diff --git a/src/components/select/select.test.ts b/src/components/select/select.test.ts index 0d676fb331..25adf9ef32 100644 --- a/src/components/select/select.test.ts +++ b/src/components/select/select.test.ts @@ -6,13 +6,13 @@ import type SlSelect from './select'; describe('', () => { it('should emit sl-change when the value changes', async () => { - const el = (await fixture(html` + const el = await fixture(html` Option 1 Option 2 Option 3 - `)) as SlSelect; + `); const changeHandler = sinon.spy(); el.addEventListener('sl-change', changeHandler); diff --git a/src/components/switch/switch.test.ts b/src/components/switch/switch.test.ts index a097e276b7..faaad61ca6 100644 --- a/src/components/switch/switch.test.ts +++ b/src/components/switch/switch.test.ts @@ -1,44 +1,54 @@ import { expect, fixture, html, oneEvent } from '@open-wc/testing'; -import { sendKeys } from '@web/test-runner-commands' +import { sendKeys } from '@web/test-runner-commands'; import '../../../dist/shoelace.js'; import type SlSwitch from './switch'; describe('', () => { it('should be disabled with the disabled attribute', async () => { - const el = await fixture(html` `); + const el = await fixture(html` `); const input = el.shadowRoot?.querySelector('input'); expect(input.disabled).to.be.true; }); it('should be valid by default', async () => { - const el = (await fixture(html` `)) + const el = await fixture(html` `); expect(el.invalid).to.be.false; }); it('should fire sl-change when clicked', async () => { - const el = (await fixture(html` `)) + const el = await fixture(html` `); setTimeout(() => el.shadowRoot?.querySelector('input').click()); - const event = await oneEvent(el, 'sl-change') + const event = await oneEvent(el, 'sl-change'); expect(event.target).to.equal(el); expect(el.checked).to.be.true; }); - it('should fire sl-change when toggled via keyboard', async () => { - const el = (await fixture(html` `)) - const input = el.shadowRoot?.querySelector('input'); - input.focus(); + it('should fire sl-change when toggled with spacebar', async () => { + const el = await fixture(html` `); + el.focus(); setTimeout(() => sendKeys({ press: ' ' })); - const event = await oneEvent(el, 'sl-change') + const event = await oneEvent(el, 'sl-change'); expect(event.target).to.equal(el); expect(el.checked).to.be.true; }); + // TODO - arrow key doesn't seem to be sending + // TODO - test for left arrow too + // it('should fire sl-change when toggled with the right arrow', async () => { + // const el = await fixture(html` `); + // el.focus(); + // setTimeout(() => sendKeys({ press: 'ArrowRight' })); + // const event = await oneEvent(el, 'sl-change'); + // expect(event.target).to.equal(el); + // expect(el.checked).to.be.true; + // }); + it('should not fire sl-change when checked is set by javascript', async () => { - const el = (await fixture(html` `)) - el.addEventListener('sl-change', () => expect.fail('event fired')) + const el = await fixture(html` `); + el.addEventListener('sl-change', () => expect.fail('event fired')); el.checked = true; await el.updateComplete; el.checked = false; diff --git a/src/components/textarea/textarea.test.ts b/src/components/textarea/textarea.test.ts index 18ce3378d5..5c54896a9f 100644 --- a/src/components/textarea/textarea.test.ts +++ b/src/components/textarea/textarea.test.ts @@ -6,26 +6,26 @@ import type SlTextarea from './textarea'; describe('', () => { it('should be disabled with the disabled attribute', async () => { - const el = await fixture(html` `); + const el = await fixture(html` `); const textarea = el.shadowRoot?.querySelector('[part="textarea"]') as HTMLInputElement; expect(textarea.disabled).to.be.true; }); it('should be valid by default', async () => { - const el = (await fixture(html` `)) as SlTextarea; + const el = await fixture(html` `); expect(el.invalid).to.be.false; }); it('should be invalid when required and empty', async () => { - const el = (await fixture(html` `)) as SlTextarea; + const el = await fixture(html` `); expect(el.invalid).to.be.true; }); it('should be invalid when required and after removing disabled ', async () => { - const el = (await fixture(html` `)) as SlTextarea; + const el = await fixture(html` `); el.disabled = false; await el.updateComplete; diff --git a/src/components/tooltip/tooltip.test.ts b/src/components/tooltip/tooltip.test.ts index d9d9dfcb8b..d7b5e1b909 100644 --- a/src/components/tooltip/tooltip.test.ts +++ b/src/components/tooltip/tooltip.test.ts @@ -6,7 +6,7 @@ import type SlTooltip from './tooltip'; describe('', () => { it('should be visible with the open attribute', async () => { - const el = await fixture(html` + const el = await fixture(html` Hover Me @@ -17,7 +17,7 @@ describe('', () => { }); it('should not be visible without the open attribute', async () => { - const el = await fixture(html` + const el = await fixture(html` Hover Me @@ -28,11 +28,11 @@ describe('', () => { }); it('should emit sl-show and sl-after-show when calling show()', async () => { - const el = (await fixture(html` + const el = await fixture(html` Hover Me - `)) as SlTooltip; + `); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; const showHandler = sinon.spy(); const afterShowHandler = sinon.spy(); @@ -50,11 +50,11 @@ describe('', () => { }); it('should emit sl-hide and sl-after-hide when calling hide()', async () => { - const el = (await fixture(html` + const el = await fixture(html` Hover Me - `)) as SlTooltip; + `); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; const hideHandler = sinon.spy(); const afterHideHandler = sinon.spy(); @@ -72,11 +72,11 @@ describe('', () => { }); it('should emit sl-show and sl-after-show when setting open = true', async () => { - const el = (await fixture(html` + const el = await fixture(html` Hover Me - `)) as SlTooltip; + `); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; const showHandler = sinon.spy(); const afterShowHandler = sinon.spy(); @@ -94,11 +94,11 @@ describe('', () => { }); it('should emit sl-hide and sl-after-hide when setting open = false', async () => { - const el = (await fixture(html` + const el = await fixture(html` Hover Me - `)) as SlTooltip; + `); const base = el.shadowRoot?.querySelector('[part="base"]') as HTMLElement; const hideHandler = sinon.spy(); const afterHideHandler = sinon.spy();