Skip to content

Commit

Permalink
test(notification): refactor event tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ogunb committed Nov 20, 2023
1 parent 4cb52fc commit ba2bfd6
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/components/notification/card/bl-notification-card.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert, expect, fixture, html, waitUntil } from "@open-wc/testing";
import { assert, expect, fixture, html, oneEvent } from "@open-wc/testing";
import { sendMouse } from "@web/test-runner-commands";
import { stub } from "sinon";
import { getMiddleOfElement } from "../../../utilities/elements";
Expand Down Expand Up @@ -66,13 +66,8 @@ describe("bl-notification-card", () => {

const remainingEl = el.shadowRoot!.querySelector(".remaining")!;

const resolveStub = stub();

remainingEl.addEventListener("animationend", resolveStub);

await waitUntil(() => resolveStub.calledOnce);

await el.updateComplete;
await oneEvent(remainingEl, "animationend");
await new Promise(resolve => setTimeout(resolve, 100));

expect(requestCloseStub).to.have.been.calledOnce;
expect(requestCloseStub.args[0][0].detail).to.deep.equal({
Expand All @@ -99,13 +94,8 @@ describe("bl-notification-card", () => {

const remainingEl = el.shadowRoot!.querySelector(".remaining")!;

const resolveStub = stub();

remainingEl.addEventListener("animationend", resolveStub);

await waitUntil(() => resolveStub.calledOnce);

await el.updateComplete;
await oneEvent(remainingEl, "animationend");
await new Promise(resolve => setTimeout(resolve, 100));

expect(requestCloseStub).to.have.been.calledOnce;
expect(closeStub).to.not.have.been.called;
Expand Down

0 comments on commit ba2bfd6

Please sign in to comment.