Skip to content

Commit

Permalink
add tests for rich text editor (bcgov#1762)
Browse files Browse the repository at this point in the history
  • Loading branch information
djnunez-aot authored Jan 29, 2024
1 parent 7ecbea4 commit 84df711
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import RichTextEditor from "../index";

describe("RichTextEditor Component Tests", () => {
it("should render the component", () => {
cy.mount(<RichTextEditor />);
});

it("should call handleEditorStateChange and setRawText when the editor state changes", () => {
const handleEditorStateChange = cy.stub();
const setRawText = cy.stub();
cy.mount(
<RichTextEditor
handleEditorStateChange={handleEditorStateChange}
setRawText={setRawText}
/>
);
cy.get('[role="textbox"]').type("Test text");

cy.wrap(setRawText).should("have.been.calledWith", "Test text");
});

it("should display helper text when error is true", () => {
cy.mount(<RichTextEditor error={true} helperText={"Error message"} />);
cy.contains("Error message").should("be.visible");
});
});

0 comments on commit 84df711

Please sign in to comment.