File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
core/src/components/checkbox/test Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -54,3 +54,33 @@ describe('ion-checkbox: indeterminate', () => {
5454 expect ( checkbox . getAttribute ( 'aria-checked' ) ) . toBe ( 'mixed' ) ;
5555 } ) ;
5656} ) ;
57+
58+ describe ( 'ion-checkbox: required' , ( ) => {
59+ it ( 'should have a required attribute in inner input when true' , async ( ) => {
60+ const page = await newSpecPage ( {
61+ components : [ Checkbox ] ,
62+ html : `
63+ <ion-checkbox required="true">Checkbox</ion-checkbox>
64+ ` ,
65+ } ) ;
66+
67+ const checkbox = page . body . querySelector ( 'ion-checkbox' ) ! ;
68+ const nativeInput = checkbox . shadowRoot ?. querySelector ( "input[type=checkbox]" ) ! ;
69+
70+ expect ( nativeInput . hasAttribute ( 'required' ) ) . toBeTruthy ( ) ;
71+ } ) ;
72+
73+ it ( 'should not have a required attribute in inner input when false' , async ( ) => {
74+ const page = await newSpecPage ( {
75+ components : [ Checkbox ] ,
76+ html : `
77+ <ion-checkbox required="false">Checkbox</ion-checkbox>
78+ ` ,
79+ } ) ;
80+
81+ const checkbox = page . body . querySelector ( 'ion-checkbox' ) ! ;
82+ const nativeInput = checkbox . shadowRoot ?. querySelector ( "input[type=checkbox]" ) ! ;
83+
84+ expect ( nativeInput . hasAttribute ( 'required' ) ) . toBeFalsy ( ) ;
85+ } ) ;
86+ } ) ;
You can’t perform that action at this time.
0 commit comments