import { html } from "lit";
import { mockRegisterOrganisation } from "@mocks/organisation.mock";
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 = 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 = 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"]
);
});
});
});
});
});