Skip to content

Commit

Permalink
Update dropdown.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
thednp committed Nov 18, 2024
1 parent 96a1b23 commit 67b6577
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions test/dropdown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,21 +226,26 @@ describe("Dropdown Class Tests", () => {
await page.viewport(800, 600);

const dropdstart = Dropdown.init(element);
await new Promise(res => setTimeout(res, 50));

element.click();
await vi.waitFor(() => {
expect(dropdstart.menu.className).to.contain("show");
expect(dropdstart.menu.style.cssText).to.contain("left: auto");
}, 351);

await new Promise(res => setTimeout(res, 50));
await page.viewport(250, 660);
win.dispatchEvent(new Event('resize'));
await vi.waitFor(() => {
expect(dropdstart.menu.style.cssText).to.contain("left: auto");
}, 551);

await new Promise(res => setTimeout(res, 50));
await page.viewport(800, 660);
win.dispatchEvent(new Event('resize'));
await new Promise(res => setTimeout(res, 50));

await vi.waitFor(() => {
expect(dropdstart.menu.style.cssText).to.contain("left: auto");
}, 351);
Expand All @@ -256,14 +261,16 @@ describe("Dropdown Class Tests", () => {
expect(dropend.menu.style.cssText).to.contain("right: auto");
}, 351);

await page.viewport(200, 660);
await new Promise(res => setTimeout(res, 50));
await page.viewport(200, 660);
win.dispatchEvent(new Event('resize'));
await new Promise(res => setTimeout(res, 50));
await new Promise(res => setTimeout(res, 150));
await vi.waitFor(() => {
expect(dropend.menu.className).to.contain("show");
expect(dropend.menu.style.cssText).to.contain("left: auto");
}, 551);
expect(dropend.menu.style.cssText).to.contain("left: 100%");
}, 351);

await new Promise(res => setTimeout(res, 50));
dropend.dispose();
Object.assign(body.style, bodyPads.reset);
await page.viewport(800, 660);
Expand Down Expand Up @@ -463,6 +470,8 @@ describe("Dropdown Class Tests", () => {
await new Promise(res => setTimeout(res, 50));
win.scrollTo({ left: 0, top: 800, behavior: "smooth" });
win.dispatchEvent(new Event('scroll'));
await new Promise(res => setTimeout(res, 50));

await vi.waitFor(() => {
expect(dropupTopLeft.menu.style.cssText).to.contain("top: 100%");
}, 551);
Expand All @@ -486,6 +495,8 @@ describe("Dropdown Class Tests", () => {
await new Promise(res => setTimeout(res, 50));
win.scrollTo({ left: 0, top: 800, behavior: "smooth" });
win.dispatchEvent(new Event('scroll'));
await new Promise(res => setTimeout(res, 50));

await vi.waitFor(() => {
expect(dropdownBottomLeft.menu.className).to.contain("show");
expect(dropdownBottomLeft.menu.style.cssText).to.contain("top: 100%");
Expand Down

0 comments on commit 67b6577

Please sign in to comment.