@skyux/forms 12.2.0 → 12.3.0

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.
@@ -510,7 +510,7 @@ class SkyCheckboxHarness extends SkyComponentHarness {
510
510
  const labelTextLabel = await this.#getLabelTextLabel();
511
511
  const label = await this.#getLabel();
512
512
  if (label) {
513
- throw new Error('`labelIsHidden` is only supported when setting the checkbox label via the `labelText` input.');
513
+ throw new Error('`labelHidden` is only supported when setting the checkbox label via the `labelText` input.');
514
514
  }
515
515
  else {
516
516
  return !(await labelTextLabel?.getText());
@@ -1525,7 +1525,7 @@ class SkyRadioHarness extends SkyComponentHarness {
1525
1525
  const labelText = await this.#getLabelText();
1526
1526
  const label = await this.#getLabel();
1527
1527
  if (label) {
1528
- throw new Error('`labelIsHidden` is only supported when setting the radio label via the `labelText` input.');
1528
+ throw new Error('`labelHidden` is only supported when setting the radio label via the `labelText` input.');
1529
1529
  }
1530
1530
  else {
1531
1531
  return !!(await labelText?.hasClass('sky-screen-reader-only'));
@@ -1725,9 +1725,152 @@ class SkyRadioGroupHarness extends SkyComponentHarness {
1725
1725
  }
1726
1726
  }
1727
1727
 
1728
+ /**
1729
+ * Harness for interacting with a toggle switch label component in tests.
1730
+ * @internal
1731
+ */
1732
+ class SkyToggleSwitchLabelHarness extends ComponentHarness {
1733
+ /**
1734
+ * @internal
1735
+ */
1736
+ static { this.hostSelector = 'sky-toggle-switch-label'; }
1737
+ #getLabelContent = this.locatorFor('span[skyTrim]');
1738
+ /**
1739
+ * Gets the text content of the toggle switch label.
1740
+ */
1741
+ async getText() {
1742
+ return await (await this.#getLabelContent()).text();
1743
+ }
1744
+ }
1745
+
1746
+ /**
1747
+ * Harness for interacting with a toggle switch component in tests.
1748
+ */
1749
+ class SkyToggleSwitchHarness extends SkyComponentHarness {
1750
+ /**
1751
+ * @internal
1752
+ */
1753
+ static { this.hostSelector = 'sky-toggle-switch'; }
1754
+ #getButton = this.locatorFor('button.sky-toggle-switch-button');
1755
+ #getLabel = this.locatorForOptional(SkyToggleSwitchLabelHarness);
1756
+ #getLabelText = this.locatorForOptional('span.sky-toggle-switch-label-text');
1757
+ /**
1758
+ * Gets a `HarnessPredicate` that can be used to search for a
1759
+ * `SkyToggleSwitchHarness` that meets certain criteria.
1760
+ */
1761
+ static with(filters) {
1762
+ return SkyToggleSwitchHarness.getDataSkyIdPredicate(filters);
1763
+ }
1764
+ /**
1765
+ * Blurs the toggle switch.
1766
+ */
1767
+ async blur() {
1768
+ await (await this.#getButton()).blur();
1769
+ }
1770
+ /**
1771
+ * Clicks the help inline button.
1772
+ */
1773
+ async clickHelpInline() {
1774
+ await (await this.#getHelpInline()).click();
1775
+ }
1776
+ /**
1777
+ * Puts the toggle switch in a checked state.
1778
+ */
1779
+ async check() {
1780
+ if (!(await this.isChecked())) {
1781
+ await this.#toggle();
1782
+ }
1783
+ }
1784
+ /**
1785
+ * Focuses the toggle switch.
1786
+ */
1787
+ async focus() {
1788
+ await (await this.#getButton()).focus();
1789
+ }
1790
+ /**
1791
+ * Gets the help popover content.
1792
+ */
1793
+ async getHelpPopoverContent() {
1794
+ return await (await this.#getHelpInline()).getPopoverContent();
1795
+ }
1796
+ /**
1797
+ * Gets the help popover title.
1798
+ */
1799
+ async getHelpPopoverTitle() {
1800
+ return await (await this.#getHelpInline()).getPopoverTitle();
1801
+ }
1802
+ /**
1803
+ * Whether the label is hidden. Only supported when using the `labelText` input to set the label.
1804
+ */
1805
+ async getLabelHidden() {
1806
+ const labelText = await this.#getLabelText();
1807
+ const labelComponent = await this.#getLabel();
1808
+ if (labelComponent) {
1809
+ throw new Error('`labelHidden` is only supported when setting the toggle switch label via the `labelText` input.');
1810
+ }
1811
+ else {
1812
+ return !(await labelText?.text());
1813
+ }
1814
+ }
1815
+ /**
1816
+ * Gets the toggle switch's label text. If the label is set via `labelText` and `labelHidden` is true,
1817
+ * the text will still be returned.
1818
+ */
1819
+ async getLabelText() {
1820
+ const labelText = await (await this.#getLabelText())?.text();
1821
+ const ariaLabel = await this.#getAriaLabel();
1822
+ return (labelText || ariaLabel || (await (await this.#getLabel())?.getText()));
1823
+ }
1824
+ /**
1825
+ * Whether the toggle switch is checked.
1826
+ */
1827
+ async isChecked() {
1828
+ return await (await this.#getButton()).hasClass('sky-toggle-switch-checked');
1829
+ }
1830
+ /**
1831
+ * Whether the toggle switch is disabled.
1832
+ */
1833
+ async isDisabled() {
1834
+ const disabled = await (await this.#getButton()).getAttribute('disabled');
1835
+ return disabled !== null;
1836
+ }
1837
+ /**
1838
+ * Whether the toggle switch is focused.
1839
+ */
1840
+ async isFocused() {
1841
+ return await (await this.#getButton()).isFocused();
1842
+ }
1843
+ /**
1844
+ * Puts the toggle switch in an unchecked state.
1845
+ */
1846
+ async uncheck() {
1847
+ if (await this.isChecked()) {
1848
+ await this.#toggle();
1849
+ }
1850
+ }
1851
+ async #getAriaLabel() {
1852
+ return await (await this.#getButton()).getAttribute('aria-label');
1853
+ }
1854
+ async #getHelpInline() {
1855
+ const harness = await this.locatorForOptional(SkyHelpInlineHarness)();
1856
+ if (harness) {
1857
+ return harness;
1858
+ }
1859
+ throw Error('No help inline found.');
1860
+ }
1861
+ async #toggle() {
1862
+ if (await this.isDisabled()) {
1863
+ throw new Error('Could not toggle the toggle switch because it is disabled.');
1864
+ }
1865
+ else {
1866
+ await (await this.#getButton()).click();
1867
+ }
1868
+ }
1869
+ }
1870
+
1728
1871
  /**
1729
1872
  * Generated bundle index. Do not edit.
1730
1873
  */
1731
1874
 
1732
- export { SkyCharacterCounterIndicatorHarness, SkyCheckboxFixture, SkyCheckboxGroupHarness, SkyCheckboxHarness, SkyCheckboxLabelHarness, SkyFieldGroupHarness, SkyFileAttachmentHarness, SkyFileDropHarness, SkyFileItemHarness, SkyFormErrorHarness, SkyFormErrorsHarness, SkyInputBoxHarness, SkyRadioFixture, SkyRadioGroupHarness, SkyRadioHarness, SkyRadioLabelHarness, provideSkyFileAttachmentTesting };
1875
+ export { SkyCharacterCounterIndicatorHarness, SkyCheckboxFixture, SkyCheckboxGroupHarness, SkyCheckboxHarness, SkyCheckboxLabelHarness, SkyFieldGroupHarness, SkyFileAttachmentHarness, SkyFileDropHarness, SkyFileItemHarness, SkyFormErrorHarness, SkyFormErrorsHarness, SkyInputBoxHarness, SkyRadioFixture, SkyRadioGroupHarness, SkyRadioHarness, SkyRadioLabelHarness, SkyToggleSwitchHarness, provideSkyFileAttachmentTesting };
1733
1876
  //# sourceMappingURL=skyux-forms-testing.mjs.map