@skyux/forms 15.0.0-alpha.15 → 15.0.0-alpha.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2124,9 +2124,142 @@ class SkyToggleSwitchHarness extends SkyComponentHarness {
|
|
|
2124
2124
|
}
|
|
2125
2125
|
}
|
|
2126
2126
|
|
|
2127
|
+
/**
|
|
2128
|
+
* Harness for interacting with a button component in tests.
|
|
2129
|
+
*/
|
|
2130
|
+
class SkyButtonHarness extends SkyComponentHarness {
|
|
2131
|
+
/**
|
|
2132
|
+
* @internal
|
|
2133
|
+
*/
|
|
2134
|
+
static { this.hostSelector = 'sky-button'; }
|
|
2135
|
+
#getButton = this.locatorForOptional('button');
|
|
2136
|
+
#getAnchor = this.locatorForOptional('a');
|
|
2137
|
+
#getIcon = this.locatorForOptional(SkyIconHarness);
|
|
2138
|
+
#getAnchorOrButton = this.locatorFor('button, a');
|
|
2139
|
+
#getLabelTextLabel = this.locatorForOptional('span');
|
|
2140
|
+
/**
|
|
2141
|
+
* Gets a `HarnessPredicate` that can be used to search for a
|
|
2142
|
+
* `SkyButtonHarness` that meets certain criteria.
|
|
2143
|
+
*/
|
|
2144
|
+
static with(filters) {
|
|
2145
|
+
return SkyButtonHarness.getDataSkyIdPredicate(filters);
|
|
2146
|
+
}
|
|
2147
|
+
/**
|
|
2148
|
+
* Blurs the button.
|
|
2149
|
+
*/
|
|
2150
|
+
async blur() {
|
|
2151
|
+
await (await this.#getAnchorOrButton())?.blur();
|
|
2152
|
+
}
|
|
2153
|
+
/**
|
|
2154
|
+
* Clicks the button.
|
|
2155
|
+
*/
|
|
2156
|
+
async click() {
|
|
2157
|
+
await (await this.#getAnchorOrButton())?.click();
|
|
2158
|
+
}
|
|
2159
|
+
/**
|
|
2160
|
+
* Focuses the button.
|
|
2161
|
+
*/
|
|
2162
|
+
async focus() {
|
|
2163
|
+
await (await this.#getAnchorOrButton())?.focus();
|
|
2164
|
+
}
|
|
2165
|
+
/**
|
|
2166
|
+
* Gets the button's style.
|
|
2167
|
+
*/
|
|
2168
|
+
async getButtonStyle() {
|
|
2169
|
+
const anchorOrButton = await this.#getAnchorOrButton();
|
|
2170
|
+
const buttonStyles = [
|
|
2171
|
+
'danger',
|
|
2172
|
+
'default',
|
|
2173
|
+
'icon-borderless',
|
|
2174
|
+
'link',
|
|
2175
|
+
'link-inline',
|
|
2176
|
+
'primary',
|
|
2177
|
+
];
|
|
2178
|
+
for (const buttonStyle of buttonStyles) {
|
|
2179
|
+
if (await anchorOrButton?.hasClass(`sky-btn-${buttonStyle}`)) {
|
|
2180
|
+
return buttonStyle;
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
/* istanbul ignore next */
|
|
2184
|
+
throw new Error('Unable to determine button style.');
|
|
2185
|
+
}
|
|
2186
|
+
/**
|
|
2187
|
+
* Gets the button's type.
|
|
2188
|
+
*/
|
|
2189
|
+
async getButtonType() {
|
|
2190
|
+
const button = await this.#getButton();
|
|
2191
|
+
return (await button?.getAttribute('type'));
|
|
2192
|
+
}
|
|
2193
|
+
/**
|
|
2194
|
+
* Gets the button's label text. If the label is set via `labelText` and `labelHidden` is true,
|
|
2195
|
+
* the text will still be returned.
|
|
2196
|
+
*/
|
|
2197
|
+
async getLabelText() {
|
|
2198
|
+
const labelTextLabel = await this.#getLabelTextLabel();
|
|
2199
|
+
if (labelTextLabel) {
|
|
2200
|
+
return await labelTextLabel.text();
|
|
2201
|
+
}
|
|
2202
|
+
return (await this.#getAriaLabel());
|
|
2203
|
+
}
|
|
2204
|
+
/**
|
|
2205
|
+
* Whether the label is hidden. Only supported when using the `labelText` input to set the label.
|
|
2206
|
+
*/
|
|
2207
|
+
async getLabelHidden() {
|
|
2208
|
+
const labelTextLabel = await this.#getLabelTextLabel();
|
|
2209
|
+
return !(await labelTextLabel?.text());
|
|
2210
|
+
}
|
|
2211
|
+
/**
|
|
2212
|
+
* Whether the button is disabled.
|
|
2213
|
+
*/
|
|
2214
|
+
async isDisabled() {
|
|
2215
|
+
const button = await this.#getButton();
|
|
2216
|
+
if (button) {
|
|
2217
|
+
return (await button.getAttribute('disabled')) !== null;
|
|
2218
|
+
}
|
|
2219
|
+
return false;
|
|
2220
|
+
}
|
|
2221
|
+
/**
|
|
2222
|
+
* Whether the button is focused.
|
|
2223
|
+
*/
|
|
2224
|
+
async isFocused() {
|
|
2225
|
+
return await (await this.#getAnchorOrButton()).isFocused();
|
|
2226
|
+
}
|
|
2227
|
+
/**
|
|
2228
|
+
* Gets the name of the displayed icon, or undefined if no icon is displayed.
|
|
2229
|
+
*/
|
|
2230
|
+
async getIconName() {
|
|
2231
|
+
return await (await this.#getIcon())?.getIconName();
|
|
2232
|
+
}
|
|
2233
|
+
/**
|
|
2234
|
+
* Whether the button is a block button.
|
|
2235
|
+
*/
|
|
2236
|
+
async isBlock() {
|
|
2237
|
+
return await (await this.#getAnchorOrButton()).hasClass('sky-btn-block');
|
|
2238
|
+
}
|
|
2239
|
+
/**
|
|
2240
|
+
* Whether the button is displaying a logo. This will return false when no icon
|
|
2241
|
+
* is displayed, even when the logo input is set to true.
|
|
2242
|
+
*/
|
|
2243
|
+
async isLogo() {
|
|
2244
|
+
const iconHost = await (await this.#getIcon())?.host();
|
|
2245
|
+
return !!(await iconHost?.hasClass('sky-btn-block-logo'));
|
|
2246
|
+
}
|
|
2247
|
+
/**
|
|
2248
|
+
* Gets the resolved URL for the current permalink, or undefined if no permalink
|
|
2249
|
+
* is specified.
|
|
2250
|
+
*/
|
|
2251
|
+
async getLink() {
|
|
2252
|
+
const anchor = await this.#getAnchor();
|
|
2253
|
+
return (await anchor?.getAttribute('href')) ?? undefined;
|
|
2254
|
+
}
|
|
2255
|
+
async #getAriaLabel() {
|
|
2256
|
+
return await (await this.#getAnchorOrButton()).getAttribute('aria-label');
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2127
2260
|
/**
|
|
2128
2261
|
* Generated bundle index. Do not edit.
|
|
2129
2262
|
*/
|
|
2130
2263
|
|
|
2131
|
-
export { SkyCharacterCounterIndicatorHarness, SkyCheckboxFixture, SkyCheckboxGroupHarness, SkyCheckboxHarness, SkyCheckboxLabelHarness, SkyFieldGroupHarness, SkyFileAttachmentHarness, SkyFileDropHarness, SkyFileItemHarness, SkyFormErrorHarness, SkyFormErrorsHarness, SkyInputBoxHarness, SkyRadioFixture, SkyRadioGroupHarness, SkyRadioHarness, SkyRadioLabelHarness, SkySelectionBoxGridHarness, SkySelectionBoxHarness, SkyToggleSwitchHarness, provideSkyFileAttachmentTesting };
|
|
2264
|
+
export { SkyButtonHarness, SkyCharacterCounterIndicatorHarness, SkyCheckboxFixture, SkyCheckboxGroupHarness, SkyCheckboxHarness, SkyCheckboxLabelHarness, SkyFieldGroupHarness, SkyFileAttachmentHarness, SkyFileDropHarness, SkyFileItemHarness, SkyFormErrorHarness, SkyFormErrorsHarness, SkyInputBoxHarness, SkyRadioFixture, SkyRadioGroupHarness, SkyRadioHarness, SkyRadioLabelHarness, SkySelectionBoxGridHarness, SkySelectionBoxHarness, SkyToggleSwitchHarness, provideSkyFileAttachmentTesting };
|
|
2132
2265
|
//# sourceMappingURL=skyux-forms-testing.mjs.map
|