mirror of
https://github.com/komodorio/helm-dashboard.git
synced 2026-03-28 07:18:03 +00:00
Adding cypress + example test (#476)
This commit is contained in:
31
frontend/src/components/Button.cy.tsx
Normal file
31
frontend/src/components/Button.cy.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import { mount } from "cypress/react18";
|
||||
import { Button } from "./common/Button/Button";
|
||||
|
||||
describe("Button component tests", () => {
|
||||
const buttonText = "buttonText";
|
||||
|
||||
it("renders", () => {
|
||||
mount(<Button onClick={() => {}}></Button>);
|
||||
cy.get("button").should("exist");
|
||||
});
|
||||
|
||||
it("Should have correct text", () => {
|
||||
mount(<Button label={buttonText} onClick={() => {}}></Button>);
|
||||
cy.get("button").contains(buttonText);
|
||||
});
|
||||
|
||||
it("calls onClick when clicked", () => {
|
||||
const onClickStub = cy.stub().as("onClick");
|
||||
|
||||
mount(<Button onClick={onClickStub}></Button>);
|
||||
|
||||
cy.get("button").click();
|
||||
cy.get("@onClick").should("have.been.calledOnce");
|
||||
});
|
||||
|
||||
it("should be disabled", () => {
|
||||
mount(<Button onClick={() => {}} disabled></Button>);
|
||||
|
||||
cy.get("button").should("be.disabled");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user