forked from bcgov/EPIC.track
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for rich text editor (bcgov#1762)
- Loading branch information
1 parent
7ecbea4
commit 84df711
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
epictrack-web/src/components/shared/richTextEditor/__test__/RichTextEditor.cy.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
}); | ||
}); |