2023-10-23 23:33:39 +02:00
|
|
|
import { FormState } from "../../../../components/design/FormState"
|
2022-08-23 21:51:20 +02:00
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
describe("<FormState />", () => {
|
|
|
|
it("should return nothing if the state is idle", () => {
|
|
|
|
cy.mount(<FormState state="idle" />)
|
|
|
|
.get("[data-cy-root]")
|
|
|
|
.should("be.empty")
|
2022-08-23 21:51:20 +02:00
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should return nothing if the message is null", () => {
|
|
|
|
cy.mount(<FormState state="error" />)
|
|
|
|
.get("[data-cy-root]")
|
|
|
|
.should("be.empty")
|
2022-08-23 21:51:20 +02:00
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should render the <Loader /> if state is loading", () => {
|
|
|
|
cy.mount(<FormState state="loading" />)
|
|
|
|
.get("[data-cy=loader]")
|
|
|
|
.should("be.visible")
|
2022-08-23 21:51:20 +02:00
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should render the success message if state is success", () => {
|
|
|
|
const message = "Success Message"
|
|
|
|
cy.mount(<FormState state="success" message={message} id="success" />)
|
|
|
|
.get("#success")
|
2022-08-23 21:51:20 +02:00
|
|
|
.contains(message)
|
|
|
|
})
|
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
it("should render the error message if state is error", () => {
|
|
|
|
const message = "Error Message"
|
|
|
|
cy.mount(<FormState state="error" message={message} id="error" />)
|
|
|
|
.get("#error")
|
2022-08-23 21:51:20 +02:00
|
|
|
.contains(message)
|
|
|
|
})
|
|
|
|
})
|