Created
November 16, 2025 18:19
-
-
Save JRJurman/6469216b460b8faf2d9aeeea05d60a47 to your computer and use it in GitHub Desktop.
Test for wa-dropdown (upgrade)
This file contains hidden or 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
| import { aTimeout, expect, fixture, html } from '@open-wc/testing'; | |
| import type WaDropdown from './dropdown.js'; | |
| describe('<wa-dropdown> (on upgrade)', () => { | |
| it('should not be open by default', async () => { | |
| const el = await fixture<WaDropdown>(html` | |
| <wa-dropdown-upgrade-1> | |
| <wa-button slot="trigger">Dropdown</wa-button> | |
| <wa-dropdown-item>One</wa-dropdown-item> | |
| </wa-dropdown-upgrade-1> | |
| `); | |
| const WaDropdownDefinition = customElements.get('wa-dropdown') as any; | |
| customElements.define('wa-dropdown-upgrade-1', class HTMLElement extends WaDropdownDefinition {}); | |
| await el.updateComplete; | |
| await aTimeout(200); | |
| expect(el.open).to.be.false; | |
| }); | |
| it('should not be open by default (when wa-hide is cancelled)', async () => { | |
| const el = await fixture<WaDropdown>(html` | |
| <wa-dropdown-upgrade-2> | |
| <wa-button slot="trigger">Dropdown</wa-button> | |
| <wa-dropdown-item>One</wa-dropdown-item> | |
| </wa-dropdown-upgrade-2> | |
| `); | |
| el.addEventListener('wa-hide', event => { | |
| event.preventDefault(); | |
| }); | |
| const WaDropdownDefinition = customElements.get('wa-dropdown') as any; | |
| customElements.define('wa-dropdown-upgrade-2', class HTMLElement extends WaDropdownDefinition {}); | |
| await el.updateComplete; | |
| await aTimeout(200); | |
| expect(el.open).to.be.false; | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment