@@ -3,12 +3,21 @@ import { AutoForm } from "@autoform/mui";
33import { YupProvider , fieldConfig } from "@autoform/yup" ;
44import * as Yup from "yup" ;
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+
614describe ( "AutoForm Basic Tests (MUI-YUP)" , ( ) => {
715 const basicSchema = Yup . object ( {
816 name : Yup . string ( ) . min ( 2 , "Name must be at least 2 characters" ) ,
917 age : Yup . number ( ) . min ( 18 , "Must be at least 18 years old" ) ,
1018 email : Yup . string ( ) . email ( "Invalid email address" ) ,
1119 website : Yup . string ( ) . url ( "Invalid URL" ) . optional ( ) ,
20+ sports : Yup . mixed ( ) . oneOf ( Object . values ( Sports ) ) ,
1221 birthdate : Yup . date ( ) ,
1322 isStudent : Yup . boolean ( ) ,
1423 } ) ;
@@ -28,6 +37,7 @@ describe("AutoForm Basic Tests (MUI-YUP)", () => {
2837 cy . get ( 'input[name="age"]' ) . should ( "have.attr" , "type" , "number" ) ;
2938 cy . get ( 'input[name="email"]' ) . should ( "exist" ) ;
3039 cy . get ( 'input[name="website"]' ) . should ( "exist" ) ;
40+ cy . get ( 'input[name="sports"]' ) . should ( "exist" ) ;
3141 cy . get ( 'input[name="birthdate"]' ) . should ( "have.attr" , "type" , "date" ) ;
3242 cy . get ( 'input[name="isStudent"]' ) . should ( "have.attr" , "type" , "checkbox" ) ;
3343 } ) ;
@@ -42,6 +52,8 @@ describe("AutoForm Basic Tests (MUI-YUP)", () => {
4252 cy . get ( 'input[name="age"]' ) . type ( "25" ) ;
4353 cy . get ( 'input[name="email"]' ) . type ( "[email protected] " ) ; 4454 cy . get ( 'input[name="website"]' ) . type ( "https://example.com" ) ;
55+ cy . get ( "#mui-component-select-sports" ) . click ( ) ;
56+ cy . get ( '.MuiMenuItem-root[data-value="Hockey (Ice)"]' ) . click ( ) ;
4557 cy . get ( 'input[name="birthdate"]' ) . type ( "1990-01-01" ) ;
4658 cy . get ( 'input[name="isStudent"]' ) . check ( ) ;
4759
@@ -53,6 +65,7 @@ describe("AutoForm Basic Tests (MUI-YUP)", () => {
5365 age : 25 ,
54665567 website : "https://example.com" ,
68+ sports : "Hockey (Ice)" ,
5669 birthdate : new Date ( "1990-01-01" ) ,
5770 isStudent : true ,
5871 } ) ;
0 commit comments