@@ -65,19 +65,19 @@ describe("calcite-link", () => {
65
65
expect ( elementAsLink ) . not . toHaveAttribute ( "download" ) ;
66
66
} ) ;
67
67
68
- it ( "renders as a span with default props" , async ( ) => {
68
+ it ( "renders as a button with default props" , async ( ) => {
69
69
const page = await newE2EPage ( ) ;
70
70
await page . setContent ( `<calcite-link>Continue</calcite-link>` ) ;
71
71
72
72
const element = await page . find ( "calcite-link" ) ;
73
- const elementAsSpan = await page . find ( "calcite-link >>> span " ) ;
73
+ const elementAsButton = await page . find ( "calcite-link >>> button " ) ;
74
74
const elementAsLink = await page . find ( "calcite-link >>> a" ) ;
75
75
const iconStart = await page . find ( "calcite-link >>> .calcite-link--icon.icon-start" ) ;
76
76
const iconEnd = await page . find ( "calcite-link >>> .calcite-link--icon.icon-end" ) ;
77
77
78
78
expect ( element ) . not . toHaveAttribute ( "icon-flip-rtl" ) ;
79
79
expect ( elementAsLink ) . toBeNull ( ) ;
80
- expect ( elementAsSpan ) . not . toBeNull ( ) ;
80
+ expect ( elementAsButton ) . not . toBeNull ( ) ;
81
81
expect ( iconStart ) . toBeNull ( ) ;
82
82
expect ( iconEnd ) . toBeNull ( ) ;
83
83
} ) ;
@@ -86,62 +86,62 @@ describe("calcite-link", () => {
86
86
const page = await newE2EPage ( { html : `<calcite-link>Continue</calcite-link>` } ) ;
87
87
const link = await page . find ( "calcite-link" ) ;
88
88
let elementAsLink : E2EElement ;
89
- let elementAsSpan : E2EElement ;
89
+ let elementAsButton : E2EElement ;
90
90
91
- elementAsSpan = await page . find ( "calcite-link >>> span " ) ;
91
+ elementAsButton = await page . find ( "calcite-link >>> button " ) ;
92
92
elementAsLink = await page . find ( "calcite-link >>> a" ) ;
93
- expect ( elementAsSpan ) . not . toBeNull ( ) ;
93
+ expect ( elementAsButton ) . not . toBeNull ( ) ;
94
94
expect ( elementAsLink ) . toBeNull ( ) ;
95
95
96
96
link . setProperty ( "href" , "/" ) ;
97
97
await page . waitForChanges ( ) ;
98
98
99
- elementAsSpan = await page . find ( "calcite-link >>> span " ) ;
99
+ elementAsButton = await page . find ( "calcite-link >>> button " ) ;
100
100
elementAsLink = await page . find ( "calcite-link >>> a" ) ;
101
- expect ( elementAsSpan ) . toBeNull ( ) ;
101
+ expect ( elementAsButton ) . toBeNull ( ) ;
102
102
expect ( elementAsLink ) . not . toBeNull ( ) ;
103
103
} ) ;
104
104
105
105
it ( "renders as a link with default props" , async ( ) => {
106
106
const page = await newE2EPage ( ) ;
107
107
await page . setContent ( `<calcite-link href="/">Continue</calcite-link>` ) ;
108
108
const element = await page . find ( "calcite-link" ) ;
109
- const elementAsSpan = await page . find ( "calcite-link >>> span " ) ;
109
+ const elementAsButton = await page . find ( "calcite-link >>> button " ) ;
110
110
const elementAsLink = await page . find ( "calcite-link >>> a" ) ;
111
111
const iconStart = await page . find ( "calcite-link >>> .calcite-link--icon.icon-start" ) ;
112
112
const iconEnd = await page . find ( "calcite-link >>> .calcite-link--icon.icon-end" ) ;
113
113
114
114
expect ( element ) . not . toHaveAttribute ( "icon-flip-rtl" ) ;
115
115
expect ( elementAsLink ) . not . toBeNull ( ) ;
116
- expect ( elementAsSpan ) . toBeNull ( ) ;
116
+ expect ( elementAsButton ) . toBeNull ( ) ;
117
117
expect ( iconStart ) . toBeNull ( ) ;
118
118
expect ( iconEnd ) . toBeNull ( ) ;
119
119
} ) ;
120
120
121
- it ( "renders as a span with requested props" , async ( ) => {
121
+ it ( "renders as a button with requested props" , async ( ) => {
122
122
const page = await newE2EPage ( ) ;
123
123
await page . setContent ( `<calcite-link>Continue</calcite-link>` ) ;
124
- const elementAsSpan = await page . find ( "calcite-link >>> span " ) ;
124
+ const elementAsButton = await page . find ( "calcite-link >>> button " ) ;
125
125
const elementAsLink = await page . find ( "calcite-link >>> a" ) ;
126
126
const iconStart = await page . find ( "calcite-link >>> .calcite-link--icon.icon-start" ) ;
127
127
const iconEnd = await page . find ( "calcite-link >>> .calcite-link--icon.icon-end" ) ;
128
128
129
129
expect ( elementAsLink ) . toBeNull ( ) ;
130
- expect ( elementAsSpan ) . not . toBeNull ( ) ;
130
+ expect ( elementAsButton ) . not . toBeNull ( ) ;
131
131
expect ( iconStart ) . toBeNull ( ) ;
132
132
expect ( iconEnd ) . toBeNull ( ) ;
133
133
} ) ;
134
134
135
135
it ( "renders as a link with requested props" , async ( ) => {
136
136
const page = await newE2EPage ( ) ;
137
137
await page . setContent ( `<calcite-link href="/">Continue</calcite-link>` ) ;
138
- const elementAsSpan = await page . find ( "calcite-link >>> span " ) ;
138
+ const elementAsButton = await page . find ( "calcite-link >>> button " ) ;
139
139
const elementAsLink = await page . find ( "calcite-link >>> a" ) ;
140
140
const iconStart = await page . find ( "calcite-link >>> .calcite-link--icon.icon-start" ) ;
141
141
const iconEnd = await page . find ( "calcite-link >>> .calcite-link--icon.icon-end" ) ;
142
142
143
143
expect ( elementAsLink ) . not . toBeNull ( ) ;
144
- expect ( elementAsSpan ) . toBeNull ( ) ;
144
+ expect ( elementAsButton ) . toBeNull ( ) ;
145
145
expect ( iconStart ) . toBeNull ( ) ;
146
146
expect ( iconEnd ) . toBeNull ( ) ;
147
147
} ) ;
@@ -151,13 +151,13 @@ describe("calcite-link", () => {
151
151
await page . setContent (
152
152
`<calcite-link rel="noopener noreferrer" target="_blank" class="my-custom-class" href="google.com">Continue</calcite-link>` ,
153
153
) ;
154
- const elementAsSpan = await page . find ( "calcite-link >>> span " ) ;
154
+ const elementAsButton = await page . find ( "calcite-link >>> button " ) ;
155
155
const elementAsLink = await page . find ( "calcite-link >>> a" ) ;
156
156
const iconStart = await page . find ( "calcite-link >>> .calcite-link--icon.icon-start" ) ;
157
157
const iconEnd = await page . find ( "calcite-link >>> .calcite-link--icon.icon-end" ) ;
158
158
159
159
expect ( elementAsLink ) . not . toBeNull ( ) ;
160
- expect ( elementAsSpan ) . toBeNull ( ) ;
160
+ expect ( elementAsButton ) . toBeNull ( ) ;
161
161
expect ( elementAsLink ) . not . toHaveClass ( "my-custom-class" ) ;
162
162
expect ( elementAsLink ) . toEqualAttribute ( "href" , "google.com" ) ;
163
163
expect ( elementAsLink ) . toEqualAttribute ( "rel" , "noopener noreferrer" ) ;
@@ -169,38 +169,38 @@ describe("calcite-link", () => {
169
169
it ( "renders with an icon-start" , async ( ) => {
170
170
const page = await newE2EPage ( ) ;
171
171
await page . setContent ( `<calcite-link icon-start='plus'>Continue</calcite-link>` ) ;
172
- const elementAsSpan = await page . find ( "calcite-link >>> span " ) ;
172
+ const elementAsButton = await page . find ( "calcite-link >>> button " ) ;
173
173
const elementAsLink = await page . find ( "calcite-link >>> a" ) ;
174
174
const iconStart = await page . find ( "calcite-link >>> .calcite-link--icon.icon-start" ) ;
175
175
const iconEnd = await page . find ( "calcite-link >>> .calcite-link--icon.icon-end" ) ;
176
176
expect ( elementAsLink ) . toBeNull ( ) ;
177
- expect ( elementAsSpan ) . not . toBeNull ( ) ;
177
+ expect ( elementAsButton ) . not . toBeNull ( ) ;
178
178
expect ( iconStart ) . not . toBeNull ( ) ;
179
179
expect ( iconEnd ) . toBeNull ( ) ;
180
180
} ) ;
181
181
182
182
it ( "renders with an icon-end" , async ( ) => {
183
183
const page = await newE2EPage ( ) ;
184
184
await page . setContent ( `<calcite-link icon-end='plus'>Continue</calcite-link>` ) ;
185
- const elementAsSpan = await page . find ( "calcite-link >>> span " ) ;
185
+ const elementAsButton = await page . find ( "calcite-link >>> button " ) ;
186
186
const elementAsLink = await page . find ( "calcite-link >>> a" ) ;
187
187
const iconStart = await page . find ( "calcite-link >>> .calcite-link--icon.icon-start" ) ;
188
188
const iconEnd = await page . find ( "calcite-link >>> .calcite-link--icon.icon-end" ) ;
189
189
expect ( elementAsLink ) . toBeNull ( ) ;
190
- expect ( elementAsSpan ) . not . toBeNull ( ) ;
190
+ expect ( elementAsButton ) . not . toBeNull ( ) ;
191
191
expect ( iconStart ) . toBeNull ( ) ;
192
192
expect ( iconEnd ) . not . toBeNull ( ) ;
193
193
} ) ;
194
194
195
195
it ( "renders with an icon-start and icon-end" , async ( ) => {
196
196
const page = await newE2EPage ( ) ;
197
197
await page . setContent ( `<calcite-link icon-start='plus' icon-end='plus'>Continue</calcite-link>` ) ;
198
- const elementAsSpan = await page . find ( "calcite-link >>> span " ) ;
198
+ const elementAsButton = await page . find ( "calcite-link >>> button " ) ;
199
199
const elementAsLink = await page . find ( "calcite-link >>> a" ) ;
200
200
const iconStart = await page . find ( "calcite-link >>> .calcite-link--icon.icon-start" ) ;
201
201
const iconEnd = await page . find ( "calcite-link >>> .calcite-link--icon.icon-end" ) ;
202
202
expect ( elementAsLink ) . toBeNull ( ) ;
203
- expect ( elementAsSpan ) . not . toBeNull ( ) ;
203
+ expect ( elementAsButton ) . not . toBeNull ( ) ;
204
204
expect ( iconStart ) . not . toBeNull ( ) ;
205
205
expect ( iconEnd ) . not . toBeNull ( ) ;
206
206
} ) ;
@@ -231,6 +231,18 @@ describe("calcite-link", () => {
231
231
expect ( page . url ( ) ) . toBe ( targetUrl ) ;
232
232
} ) ;
233
233
234
+ it ( "keyboard without href" , async ( ) => {
235
+ const element = await page . find ( "calcite-link" ) ;
236
+ element . setProperty ( "href" , undefined ) ;
237
+ const clickEvent = await element . spyOnEvent ( "click" ) ;
238
+
239
+ await element . callMethod ( "setFocus" ) ;
240
+ await page . waitForChanges ( ) ;
241
+ await page . keyboard . press ( "Enter" ) ;
242
+ await page . waitForChanges ( ) ;
243
+ expect ( clickEvent ) . toHaveReceivedEventTimes ( 1 ) ;
244
+ } ) ;
245
+
234
246
it ( "mouse" , async ( ) => {
235
247
// workaround for https://github.com/puppeteer/puppeteer/issues/2977
236
248
await page . $eval ( "calcite-link" , ( link : HTMLElement ) : void => {
0 commit comments