Skip to content

Commit

Permalink
test(popup): add test for positioning behavior on active state change
Browse files Browse the repository at this point in the history
  • Loading branch information
Masty88 committed Nov 19, 2024
1 parent 9ab830a commit 594b78a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/components/popup/popup.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
import '../../../dist/shoelace.js';
import { expect, fixture, html } from '@open-wc/testing';
import type SlPopup from './popup.js';

describe('<sl-popup>', () => {
let element: SlPopup;

it('should render a component', async () => {
const el = await fixture(html` <sl-popup></sl-popup> `);

expect(el).to.exist;
});

it('should properly handle positioning when active changes', async () => {
element = await fixture('<sl-popup></sl-popup>');

element.active = true;
await el.updateComplete;

// SImulate a scroll event
const event = new Event('scroll');
window.dispatchEvent(event);

element.active = false;
await element.updateComplete;

// The component should not throw an error when the window is scrolled
expect(() => {
element.active = true;
window.dispatchEvent(event);
}).not.to.throw();
});
});

0 comments on commit 594b78a

Please sign in to comment.