import { html } from "lit";
// Inlined: importing Mocks from solid-tems-shared stalls Vite optimize-deps in CI.
const Mocks = {
organisation: {
mockRegisterOrganisation: () => ({
"@id": "http://example.com/organisations/1",
email: "john@doe",
organisation: "Mock Organisation",
organisationAddress: "123 Mock St",
organisationRegistrationNumber: "MOCK123",
firstname: "John",
lastname: "Doe",
status: "pending" as const,
optin_register: true,
}),
},
};
describe("", () => {
beforeEach(() => {
cy.window().then((win) => {
win.sibStore = {
patch: cy.stub().resolves({}),
getData: cy.stub().resolves([]),
};
});
});
it("should mount", () => {
cy.mount(
html``,
);
cy.get("solid-tems-organisation-approval").should("exist");
});
describe("_rotateSort", () => {
it("should rotate sort direction and property", () => {
const mockOrg = Mocks.organisation.mockRegisterOrganisation();
cy.mount(
html``,
);
cy.get("solid-tems-organisation-approval").as("component");
cy.get("@component").invoke("prop", "sortBy").should("eq", "");
cy.get("@component").invoke("prop", "sortDir").should("eq", undefined);
cy.get("th").contains("Organisation").click();
cy.get("@component")
.invoke("prop", "sortBy")
.should("eq", "organisation");
cy.get("@component").invoke("prop", "sortDir").should("eq", "asc");
cy.get("th").contains("Organisation").click();
cy.get("@component")
.invoke("prop", "sortBy")
.should("eq", "organisation");
cy.get("@component").invoke("prop", "sortDir").should("eq", "desc");
cy.get("th").contains("Organisation").click();
cy.get("@component").invoke("prop", "sortBy").should("eq", "");
cy.get("@component").invoke("prop", "sortDir").should("eq", undefined);
cy.get("th").contains("Address").click();
cy.get("@component")
.invoke("prop", "sortBy")
.should("eq", "organisationAddress");
cy.get("@component").invoke("prop", "sortDir").should("eq", "asc");
});
});
describe("_updateOrganisationStatus", () => {
it("should call sibStore.patch", () => {
const mockOrg = Mocks.organisation.mockRegisterOrganisation();
cy.mount(
html``,
);
cy.get("solid-tems-organisation-approval").then(async () => {
cy.get("tems-button[label='Approve']").click();
cy.window().then((win) => {
expect(win.sibStore.patch).to.have.been.calledOnceWith(
mockOrg,
mockOrg["@id"],
);
});
});
});
});
});