Skip to content

Commit 6849e21

Browse files
tests: add ant-joi tests (native Enum)
1 parent 926f9dc commit 6849e21

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

apps/web/cypress/component/autoform/ant-joi/basics.cy.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ import Joi from "joi";
33
import { AutoForm } from "@autoform/ant";
44
import { JoiProvider } from "@autoform/joi";
55

6+
enum Sports {
7+
Football = "Football/Soccer",
8+
Basketball = "Basketballs",
9+
Baseball = "Baseballs",
10+
Hockey = "Hockey (Ice)",
11+
None = "I don't like sports",
12+
}
13+
614
describe("AutoForm Basic Tests (ANT-JOI)", () => {
715
const basicSchema = Joi.object({
816
name: Joi.string().min(2).required().messages({
@@ -20,6 +28,7 @@ describe("AutoForm Basic Tests (ANT-JOI)", () => {
2028
website: Joi.string().uri().optional().messages({
2129
"string.uri": "Invalid URL",
2230
}),
31+
sports: Joi.valid(...Object.values(Sports)),
2332
birthdate: Joi.date().required(),
2433
isStudent: Joi.boolean().required(),
2534
});
@@ -39,11 +48,12 @@ describe("AutoForm Basic Tests (ANT-JOI)", () => {
3948
cy.get('input[name="age"]').should("have.class", "ant-input-number-input");
4049
cy.get('input[name="email"]').should("exist");
4150
cy.get('input[name="website"]').should("exist");
42-
cy.get('input[name="birthdate"]');
4351
cy.get('input[name="isStudent"]').should(
4452
"have.class",
4553
"ant-checkbox-input"
4654
);
55+
cy.get('input[id="sports"]').should("exist");
56+
cy.get('input[name="birthdate"]');
4757
});
4858

4959
it("submits form with correct data types", () => {
@@ -56,6 +66,8 @@ describe("AutoForm Basic Tests (ANT-JOI)", () => {
5666
cy.get('input[name="age"]').type("25");
5767
cy.get('input[name="email"]').type("[email protected]");
5868
cy.get('input[name="website"]').type("https://example.com");
69+
cy.get('input[id="sports"]').click();
70+
cy.get('.ant-select-item-option[title="Hockey (Ice)"]').click();
5971
cy.get('input[name="birthdate"]').clear().type("1990-01-01");
6072
cy.get('input[name="isStudent"]').check();
6173

@@ -67,6 +79,7 @@ describe("AutoForm Basic Tests (ANT-JOI)", () => {
6779
age: 25,
6880
6981
website: "https://example.com",
82+
sports: "Hockey (Ice)",
7083
birthdate: new Date("1990-01-01"),
7184
isStudent: true,
7285
});

0 commit comments

Comments
 (0)