@@ -74,4 +74,83 @@ describe('LinkMixin', () => {
7474 } ) ;
7575 } ) ;
7676
77+ describe ( 'getNewWindowDescription' , ( ) => {
78+
79+ it ( 'should return localized string when target is _blank and label is provided' , async ( ) => {
80+ const elem = await fixture ( newWindowFixture ) ;
81+ const description = elem . getNewWindowDescription ( 'My Label' ) ;
82+ expect ( description ) . to . equal ( 'Opens in a new window.' ) ;
83+ } ) ;
84+
85+ it ( 'should return undefined when target is not _blank' , async ( ) => {
86+ const elem = await fixture ( emptyFixture ) ;
87+ const description = elem . getNewWindowDescription ( 'My Label' ) ;
88+ expect ( description ) . to . be . undefined ;
89+ } ) ;
90+
91+ it ( 'should return undefined when label is not provided' , async ( ) => {
92+ const elem = await fixture ( newWindowFixture ) ;
93+ const description = elem . getNewWindowDescription ( ) ;
94+ expect ( description ) . to . be . undefined ;
95+ } ) ;
96+
97+ } ) ;
98+
99+ describe ( '_render parameters' , ( ) => {
100+
101+ it ( 'should apply rel attribute when provided' , async ( ) => {
102+ const tagNameWithRel = defineCE (
103+ class extends LinkMixin ( LitElement ) {
104+ render ( ) {
105+ return this . _render ( html `Link Test` , { rel : 'noopener noreferrer' } ) ;
106+ }
107+ }
108+ ) ;
109+ const elem = await fixture ( `<${ tagNameWithRel } ></${ tagNameWithRel } >` ) ;
110+ const anchor = elem . shadowRoot . querySelector ( 'a' ) ;
111+ expect ( anchor . getAttribute ( 'rel' ) ) . to . equal ( 'noopener noreferrer' ) ;
112+ } ) ;
113+
114+ it ( 'should apply custom link classes' , async ( ) => {
115+ const tagNameWithClasses = defineCE (
116+ class extends LinkMixin ( LitElement ) {
117+ render ( ) {
118+ return this . _render ( html `Link Test` , { linkClasses : { 'custom-class' : true , 'another-class' : true } } ) ;
119+ }
120+ }
121+ ) ;
122+ const elem = await fixture ( `<${ tagNameWithClasses } ></${ tagNameWithClasses } >` ) ;
123+ const anchor = elem . shadowRoot . querySelector ( 'a' ) ;
124+ expect ( anchor . classList . contains ( 'custom-class' ) ) . to . be . true ;
125+ expect ( anchor . classList . contains ( 'another-class' ) ) . to . be . true ;
126+ } ) ;
127+
128+ it ( 'should apply custom tabindex' , async ( ) => {
129+ const tagNameWithTabindex = defineCE (
130+ class extends LinkMixin ( LitElement ) {
131+ render ( ) {
132+ return this . _render ( html `Link Test` , { tabindex : '-1' } ) ;
133+ }
134+ }
135+ ) ;
136+ const elem = await fixture ( `<${ tagNameWithTabindex } ></${ tagNameWithTabindex } >` ) ;
137+ const anchor = elem . shadowRoot . querySelector ( 'a' ) ;
138+ expect ( anchor . getAttribute ( 'tabindex' ) ) . to . equal ( '-1' ) ;
139+ } ) ;
140+
141+ it ( 'should apply ariaLabel when provided' , async ( ) => {
142+ const tagNameWithAriaLabel = defineCE (
143+ class extends LinkMixin ( LitElement ) {
144+ render ( ) {
145+ return this . _render ( html `Link Test` , { ariaLabel : 'Custom Label' } ) ;
146+ }
147+ }
148+ ) ;
149+ const elem = await fixture ( `<${ tagNameWithAriaLabel } ></${ tagNameWithAriaLabel } >` ) ;
150+ const anchor = elem . shadowRoot . querySelector ( 'a' ) ;
151+ expect ( anchor . getAttribute ( 'aria-label' ) ) . to . equal ( 'Custom Label' ) ;
152+ } ) ;
153+
154+ } ) ;
155+
77156} ) ;
0 commit comments