@@ -8,7 +8,8 @@ it('should inherit attributes', async () => {
88 html : '<ion-textarea title="my title" tabindex="-1" data-form-type="password"></ion-textarea>' ,
99 } ) ;
1010
11- const nativeEl = page . body . querySelector ( 'ion-textarea textarea' ) ! ;
11+ const textareaEl = page . body . querySelector ( 'ion-textarea' ) ! ;
12+ const nativeEl = textareaEl . shadowRoot ! . querySelector ( 'textarea' ) ! ;
1213 expect ( nativeEl . getAttribute ( 'title' ) ) . toBe ( 'my title' ) ;
1314 expect ( nativeEl . getAttribute ( 'tabindex' ) ) . toBe ( '-1' ) ;
1415 expect ( nativeEl . getAttribute ( 'data-form-type' ) ) . toBe ( 'password' ) ;
@@ -21,7 +22,7 @@ it('should inherit watched attributes', async () => {
2122 } ) ;
2223
2324 const textareaEl = page . body . querySelector ( 'ion-textarea' ) ! ;
24- const nativeEl = textareaEl . querySelector ( 'textarea' ) ! ;
25+ const nativeEl = textareaEl . shadowRoot ! . querySelector ( 'textarea' ) ! ;
2526
2627 expect ( nativeEl . getAttribute ( 'dir' ) ) . toBe ( 'ltr' ) ;
2728
@@ -52,7 +53,7 @@ describe('textarea: label rendering', () => {
5253
5354 const textarea = page . body . querySelector ( 'ion-textarea' ) ! ;
5455
55- const labelText = textarea . querySelector ( '.label-text-wrapper' ) ! ;
56+ const labelText = textarea . shadowRoot ! . querySelector ( '.label-text-wrapper' ) ! ;
5657
5758 expect ( labelText . textContent ) . toBe ( 'Label Prop Text' ) ;
5859 } ) ;
@@ -66,9 +67,16 @@ describe('textarea: label rendering', () => {
6667
6768 const textarea = page . body . querySelector ( 'ion-textarea' ) ! ;
6869
69- const labelText = textarea . querySelector ( '.label-text-wrapper' ) ! ;
70+ // When using a slot, the content is in the light DOM, not directly
71+ // accessible via textContent. Check that the slot element exists and
72+ // the slotted content is in the light DOM.
73+ const slotEl = textarea . shadowRoot ! . querySelector ( 'slot[name="label"]' ) ;
74+ const propEl = textarea . shadowRoot ! . querySelector ( '.label-text' ) ;
75+ const slottedContent = textarea . querySelector ( '[slot="label"]' ) ;
7076
71- expect ( labelText . textContent ) . toBe ( 'Label Prop Slot' ) ;
77+ expect ( slotEl ) . not . toBe ( null ) ;
78+ expect ( propEl ) . toBe ( null ) ;
79+ expect ( slottedContent ?. textContent ) . toBe ( 'Label Prop Slot' ) ;
7280 } ) ;
7381 it ( 'should render label prop if both prop and slot provided' , async ( ) => {
7482 const page = await newSpecPage ( {
@@ -80,7 +88,7 @@ describe('textarea: label rendering', () => {
8088
8189 const textarea = page . body . querySelector ( 'ion-textarea' ) ! ;
8290
83- const labelText = textarea . querySelector ( '.label-text-wrapper' ) ! ;
91+ const labelText = textarea . shadowRoot ! . querySelector ( '.label-text-wrapper' ) ! ;
8492
8593 expect ( labelText . textContent ) . toBe ( 'Label Prop Text' ) ;
8694 } ) ;
0 commit comments