fixed some failing jasmine tests stemming from previous commit
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
@@ -127,10 +127,30 @@ describe("RoleSelect", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ------------------------------------------------------------------ //
|
// ------------------------------------------------------------------ //
|
||||||
// room:roles_revealed event //
|
// room:all_roles_filled event //
|
||||||
// ------------------------------------------------------------------ //
|
// ------------------------------------------------------------------ //
|
||||||
|
|
||||||
describe("room:roles_revealed event", () => {
|
describe("room:all_roles_filled event", () => {
|
||||||
|
let pickSigsWrap;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
pickSigsWrap = document.createElement("div");
|
||||||
|
pickSigsWrap.id = "id_pick_sigs_wrap";
|
||||||
|
pickSigsWrap.style.display = "none";
|
||||||
|
testDiv.appendChild(pickSigsWrap);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("shows #id_pick_sigs_wrap", () => {
|
||||||
|
window.dispatchEvent(new CustomEvent("room:all_roles_filled", { detail: {} }));
|
||||||
|
expect(pickSigsWrap.style.display).toBe("");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------ //
|
||||||
|
// room:sig_select_started event //
|
||||||
|
// ------------------------------------------------------------------ //
|
||||||
|
|
||||||
|
describe("room:sig_select_started event", () => {
|
||||||
let reloadCalled;
|
let reloadCalled;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -143,7 +163,7 @@ describe("RoleSelect", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("triggers a page reload", () => {
|
it("triggers a page reload", () => {
|
||||||
window.dispatchEvent(new CustomEvent("room:roles_revealed", { detail: {} }));
|
window.dispatchEvent(new CustomEvent("room:sig_select_started", { detail: {} }));
|
||||||
expect(reloadCalled).toBe(true);
|
expect(reloadCalled).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -485,7 +485,7 @@ describe("Tray", () => {
|
|||||||
expect(firstCell.classList.contains("arc-in")).toBe(true);
|
expect(firstCell.classList.contains("arc-in")).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("removes .arc-in and force-closes after animationend", () => {
|
it("removes .arc-in and closes after animationend", () => {
|
||||||
Tray.placeCard("PC", null);
|
Tray.placeCard("PC", null);
|
||||||
expect(Tray.isOpen()).toBe(true);
|
expect(Tray.isOpen()).toBe(true);
|
||||||
firstCell.dispatchEvent(new Event("animationend"));
|
firstCell.dispatchEvent(new Event("animationend"));
|
||||||
@@ -497,6 +497,10 @@ describe("Tray", () => {
|
|||||||
let called = false;
|
let called = false;
|
||||||
Tray.placeCard("PC", () => { called = true; });
|
Tray.placeCard("PC", () => { called = true; });
|
||||||
firstCell.dispatchEvent(new Event("animationend"));
|
firstCell.dispatchEvent(new Event("animationend"));
|
||||||
|
// Simulate the close transition completing (portrait: 'left' property)
|
||||||
|
const te = new Event("transitionend");
|
||||||
|
te.propertyName = "left";
|
||||||
|
wrap.dispatchEvent(te);
|
||||||
expect(called).toBe(true);
|
expect(called).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -127,10 +127,30 @@ describe("RoleSelect", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ------------------------------------------------------------------ //
|
// ------------------------------------------------------------------ //
|
||||||
// room:roles_revealed event //
|
// room:all_roles_filled event //
|
||||||
// ------------------------------------------------------------------ //
|
// ------------------------------------------------------------------ //
|
||||||
|
|
||||||
describe("room:roles_revealed event", () => {
|
describe("room:all_roles_filled event", () => {
|
||||||
|
let pickSigsWrap;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
pickSigsWrap = document.createElement("div");
|
||||||
|
pickSigsWrap.id = "id_pick_sigs_wrap";
|
||||||
|
pickSigsWrap.style.display = "none";
|
||||||
|
testDiv.appendChild(pickSigsWrap);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("shows #id_pick_sigs_wrap", () => {
|
||||||
|
window.dispatchEvent(new CustomEvent("room:all_roles_filled", { detail: {} }));
|
||||||
|
expect(pickSigsWrap.style.display).toBe("");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------ //
|
||||||
|
// room:sig_select_started event //
|
||||||
|
// ------------------------------------------------------------------ //
|
||||||
|
|
||||||
|
describe("room:sig_select_started event", () => {
|
||||||
let reloadCalled;
|
let reloadCalled;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -143,7 +163,7 @@ describe("RoleSelect", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("triggers a page reload", () => {
|
it("triggers a page reload", () => {
|
||||||
window.dispatchEvent(new CustomEvent("room:roles_revealed", { detail: {} }));
|
window.dispatchEvent(new CustomEvent("room:sig_select_started", { detail: {} }));
|
||||||
expect(reloadCalled).toBe(true);
|
expect(reloadCalled).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -173,7 +193,6 @@ describe("RoleSelect", () => {
|
|||||||
|
|
||||||
trayWrap = document.createElement("div");
|
trayWrap = document.createElement("div");
|
||||||
trayWrap.id = "id_tray_wrap";
|
trayWrap.id = "id_tray_wrap";
|
||||||
// Simulate server-side class during ROLE_SELECT
|
|
||||||
trayWrap.className = "role-select-phase";
|
trayWrap.className = "role-select-phase";
|
||||||
testDiv.appendChild(trayWrap);
|
testDiv.appendChild(trayWrap);
|
||||||
});
|
});
|
||||||
@@ -186,6 +205,13 @@ describe("RoleSelect", () => {
|
|||||||
expect(Tray.forceClose).toHaveBeenCalled();
|
expect(Tray.forceClose).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("clears .active from all seats on turn change", () => {
|
||||||
|
window.dispatchEvent(new CustomEvent("room:turn_changed", {
|
||||||
|
detail: { active_slot: 2 }
|
||||||
|
}));
|
||||||
|
expect(testDiv.querySelector(".table-seat.active")).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
it("re-adds role-select-phase to tray wrap on turn change", () => {
|
it("re-adds role-select-phase to tray wrap on turn change", () => {
|
||||||
trayWrap.classList.remove("role-select-phase"); // simulate it was shown
|
trayWrap.classList.remove("role-select-phase"); // simulate it was shown
|
||||||
window.dispatchEvent(new CustomEvent("room:turn_changed", {
|
window.dispatchEvent(new CustomEvent("room:turn_changed", {
|
||||||
@@ -194,13 +220,6 @@ describe("RoleSelect", () => {
|
|||||||
expect(trayWrap.classList.contains("role-select-phase")).toBe(true);
|
expect(trayWrap.classList.contains("role-select-phase")).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("clears .active from all seats on turn change", () => {
|
|
||||||
window.dispatchEvent(new CustomEvent("room:turn_changed", {
|
|
||||||
detail: { active_slot: 2 }
|
|
||||||
}));
|
|
||||||
expect(testDiv.querySelector(".table-seat.active")).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("removes .active from the previously active seat", () => {
|
it("removes .active from the previously active seat", () => {
|
||||||
window.dispatchEvent(new CustomEvent("room:turn_changed", {
|
window.dispatchEvent(new CustomEvent("room:turn_changed", {
|
||||||
detail: { active_slot: 2 }
|
detail: { active_slot: 2 }
|
||||||
|
|||||||
@@ -485,7 +485,7 @@ describe("Tray", () => {
|
|||||||
expect(firstCell.classList.contains("arc-in")).toBe(true);
|
expect(firstCell.classList.contains("arc-in")).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("removes .arc-in and force-closes after animationend", () => {
|
it("removes .arc-in and closes after animationend", () => {
|
||||||
Tray.placeCard("PC", null);
|
Tray.placeCard("PC", null);
|
||||||
expect(Tray.isOpen()).toBe(true);
|
expect(Tray.isOpen()).toBe(true);
|
||||||
firstCell.dispatchEvent(new Event("animationend"));
|
firstCell.dispatchEvent(new Event("animationend"));
|
||||||
@@ -497,6 +497,10 @@ describe("Tray", () => {
|
|||||||
let called = false;
|
let called = false;
|
||||||
Tray.placeCard("PC", () => { called = true; });
|
Tray.placeCard("PC", () => { called = true; });
|
||||||
firstCell.dispatchEvent(new Event("animationend"));
|
firstCell.dispatchEvent(new Event("animationend"));
|
||||||
|
// Simulate the close transition completing (portrait: 'left' property)
|
||||||
|
const te = new Event("transitionend");
|
||||||
|
te.propertyName = "left";
|
||||||
|
wrap.dispatchEvent(te);
|
||||||
expect(called).toBe(true);
|
expect(called).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user