Skip to content

Commit

Permalink
test: add test for delay capability
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiBaicu26 committed Oct 31, 2023
1 parent b749417 commit b2b11d1
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions packages/overlay/test/overlay-trigger-click.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import {
} from '@open-wc/testing';
import type { Popover } from '@spectrum-web-components/popover';
import '@spectrum-web-components/popover/sp-popover.js';
import '@spectrum-web-components/tooltip/sp-tooltip.js';

import '@spectrum-web-components/button/sp-button.js';
import '@spectrum-web-components/action-button/sp-action-button.js';
import '@spectrum-web-components/icons-workflow/icons/sp-icon-magnify.js';
import {
Expand Down Expand Up @@ -174,4 +177,37 @@ describe('Overlay Trigger - Click', () => {
);
expect(el.open).to.equal('click');
});

it('opens with a delay on click', async () => {
const openedSpy = spy();
const closedSpy = spy();

const start = performance.now();

const el = await fixture<OverlayTrigger>(html`
<overlay-trigger
placement="right-start"
@sp-opened=${() => openedSpy()}
@sp-closed=${() => closedSpy()}
>
<sp-button slot="trigger" variant="primary"></sp-button>
<sp-tooltip
slot="click-content"
id="content"
delayed
></sp-tooltip>
</overlay-trigger>
`);

await elementUpdated(el);
el.setAttribute('open', 'click');
await waitUntil(
() => openedSpy.calledOnce,
'hover content projected to overlay',
{ timeout: 8000 }
);

const end = performance.now();
expect(end - start).to.be.greaterThan(1000);
});
});

0 comments on commit b2b11d1

Please sign in to comment.