import '../../../dist/zn.min.js'; import { expect, fixture, html, oneEvent } from '@open-wc/testing'; // ZnButton overrides click() without dispatching a DOM event, so fire a real one. const clickButton = (button: HTMLElement) => button.dispatchEvent(new MouseEvent('click', { bubbles: true, composed: true, cancelable: true })); describe('', () => { it('should render a component', async () => { const el = await fixture(html` `); expect(el).to.exist; }); it('should emit zn-cancel when the cancel button is clicked', async () => { const el = await fixture(html` `); const cancel = el.shadowRoot!.querySelector('[part="cancel-button"]')!; const listener = oneEvent(el, 'zn-cancel'); clickButton(cancel); expect(await listener).to.exist; }); it('should close a containing dialog when the cancel button is clicked', async () => { const dialog = await fixture(html`
`); const actions = dialog.querySelector('zn-form-actions')!; const cancel = actions.shadowRoot!.querySelector('[part="cancel-button"]')!; clickButton(cancel); expect(dialog.open).to.be.false; }); });