@noctuatech/uswds 1.3.2 → 1.3.4
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.
- package/package.json +5 -5
- package/src/lib/accordion/{accordion.test.ts → accordion.element.test.ts} +28 -31
- package/src/lib/accordion/accordion.element.ts +9 -7
- package/src/lib/alert/{alert.test.ts → alert.element.test.ts} +5 -6
- package/src/lib/alert/alert.element.ts +6 -4
- package/src/lib/breadcrumbs/breadcrumb/breadcrumb.element.ts +10 -10
- package/src/lib/breadcrumbs/breadcrumbs.element.test.ts +23 -0
- package/src/lib/button/button.element.test.ts +15 -0
- package/src/lib/button/button.element.ts +37 -42
- package/src/lib/button-group/button-group.element.test.ts +13 -0
- package/src/lib/card/{card.test.ts → card.element.test.ts} +12 -12
- package/src/lib/checkbox/{checkbox.test.ts → checkbox.element.test.ts} +15 -17
- package/src/lib/checkbox/checkbox.element.ts +28 -32
- package/src/lib/checkbox/checkbox.stories.ts +17 -33
- package/src/lib/collection/collection-item/collection-item.element.test.ts +15 -0
- package/src/lib/collection/collection.element.test.ts +13 -0
- package/src/lib/combo-box/{combo-box.test.ts → combo-box.element.test.ts} +64 -93
- package/src/lib/config/config.element.test.ts +13 -0
- package/src/lib/description/description.element.test.ts +13 -0
- package/src/lib/file-input/file-input-preview/file-input-preview.element.test.ts +93 -0
- package/src/lib/file-input/file-input-preview/file-input-preview.element.ts +15 -13
- package/src/lib/file-input/file-input.element.test.ts +73 -0
- package/src/lib/file-input/file-input.element.ts +10 -20
- package/src/lib/in-page-nav/in-page-nav-item/in-page-nav-item.element.ts +20 -20
- package/src/lib/in-page-nav/{in-page-nav.test.ts → in-page-nav.element.test.ts} +18 -21
- package/src/lib/input/{input.test.ts → input.element.test.ts} +11 -0
- package/src/lib/input/input.element.ts +57 -41
- package/src/lib/input-mask/input-mask.element.ts +1 -1
- package/src/lib/input-mask/input-mask.stories.ts +2 -0
- package/src/lib/link/link.element.ts +18 -25
- package/src/lib/modal/modal-close/modal-close.element.test.ts +13 -0
- package/src/lib/modal/modal-heading/modal-heading.element.test.ts +15 -0
- package/src/lib/modal/modal.element.test.ts +23 -0
- package/src/lib/pagination/pagination-item/pagination-item.element.ts +9 -6
- package/src/lib/pagination/pagination-no/pagination-no.element.ts +17 -17
- package/src/lib/pagination/pagination.element.test.ts +13 -0
- package/src/lib/process-list/{process-list.test.ts → process-list.element.test.ts} +19 -12
- package/src/lib/radio/radio-option/radio-option.element.test.ts +20 -0
- package/src/lib/radio/radio.element.test.ts +121 -0
- package/src/lib/range-slider/range-slider.element.test.ts +57 -0
- package/src/lib/range-slider/range-slider.element.ts +48 -33
- package/src/lib/search/search.element.test.ts +71 -0
- package/src/lib/select/{select.test.ts → select.element.test.ts} +23 -26
- package/src/lib/select/select.element.ts +31 -32
- package/src/lib/side-nav/{side-nav.test.ts → side-nav.element.test.ts} +13 -23
- package/src/lib/step-indicator/step/step.element.ts +16 -16
- package/src/lib/step-indicator/{step-indicator.test.ts → step-indicator.element.test.ts} +6 -6
- package/src/lib/summary-box/summary-box.element.test.ts +13 -0
- package/src/lib/tag/tag.element.test.ts +13 -0
- package/src/lib/textarea/{textarea.test.ts → textarea.element.test.ts} +13 -13
- package/src/lib/textarea/textarea.element.ts +23 -24
- package/target/lib/accordion/accordion.element.js +4 -2
- package/target/lib/accordion/accordion.element.js.map +1 -1
- package/target/lib/accordion/accordion.element.test.d.ts +1 -0
- package/target/lib/accordion/{accordion.test.js → accordion.element.test.js} +19 -19
- package/target/lib/accordion/accordion.element.test.js.map +1 -0
- package/target/lib/alert/alert.element.js +4 -2
- package/target/lib/alert/alert.element.js.map +1 -1
- package/target/lib/alert/alert.element.test.d.ts +1 -0
- package/target/lib/alert/{alert.test.js → alert.element.test.js} +5 -5
- package/target/lib/alert/alert.element.test.js.map +1 -0
- package/target/lib/breadcrumbs/breadcrumb/breadcrumb.element.d.ts +1 -1
- package/target/lib/breadcrumbs/breadcrumb/breadcrumb.element.js +6 -6
- package/target/lib/breadcrumbs/breadcrumbs.element.test.d.ts +2 -0
- package/target/lib/breadcrumbs/{breadcrumbs.test.js → breadcrumbs.element.test.js} +6 -6
- package/target/lib/breadcrumbs/breadcrumbs.element.test.js.map +1 -0
- package/target/lib/button/button.element.d.ts +3 -3
- package/target/lib/button/button.element.js +17 -23
- package/target/lib/button/button.element.js.map +1 -1
- package/target/lib/button/button.element.test.d.ts +1 -0
- package/target/lib/button/button.element.test.js +12 -0
- package/target/lib/button/button.element.test.js.map +1 -0
- package/target/lib/button-group/button-group.element.test.d.ts +1 -0
- package/target/lib/button-group/button-group.element.test.js +9 -0
- package/target/lib/button-group/button-group.element.test.js.map +1 -0
- package/target/lib/card/card.element.test.d.ts +6 -0
- package/target/lib/card/{card.test.js → card.element.test.js} +10 -10
- package/target/lib/card/card.element.test.js.map +1 -0
- package/target/lib/checkbox/checkbox.element.d.ts +3 -2
- package/target/lib/checkbox/checkbox.element.js +21 -22
- package/target/lib/checkbox/checkbox.element.js.map +1 -1
- package/target/lib/checkbox/checkbox.element.test.d.ts +1 -0
- package/target/lib/checkbox/{checkbox.test.js → checkbox.element.test.js} +13 -12
- package/target/lib/checkbox/checkbox.element.test.js.map +1 -0
- package/target/lib/checkbox/checkbox.stories.d.ts +2 -2
- package/target/lib/checkbox/checkbox.stories.js +6 -6
- package/target/lib/checkbox/checkbox.stories.js.map +1 -1
- package/target/lib/collection/collection-item/collection-item.element.test.d.ts +1 -0
- package/target/lib/collection/collection-item/collection-item.element.test.js +9 -0
- package/target/lib/collection/collection-item/collection-item.element.test.js.map +1 -0
- package/target/lib/collection/collection.element.test.d.ts +1 -0
- package/target/lib/collection/collection.element.test.js +9 -0
- package/target/lib/collection/collection.element.test.js.map +1 -0
- package/target/lib/combo-box/combo-box.element.test.d.ts +3 -0
- package/target/lib/combo-box/{combo-box.test.js → combo-box.element.test.js} +60 -60
- package/target/lib/combo-box/combo-box.element.test.js.map +1 -0
- package/target/lib/config/config.element.test.d.ts +1 -0
- package/target/lib/config/config.element.test.js +9 -0
- package/target/lib/config/config.element.test.js.map +1 -0
- package/target/lib/description/description.element.test.d.ts +1 -0
- package/target/lib/description/description.element.test.js +9 -0
- package/target/lib/description/description.element.test.js.map +1 -0
- package/target/lib/file-input/file-input-preview/file-input-preview.element.js +12 -10
- package/target/lib/file-input/file-input-preview/file-input-preview.element.js.map +1 -1
- package/target/lib/file-input/file-input-preview/file-input-preview.element.test.d.ts +2 -0
- package/target/lib/file-input/file-input-preview/{file-input-preview.test.js → file-input-preview.element.test.js} +24 -24
- package/target/lib/file-input/file-input-preview/file-input-preview.element.test.js.map +1 -0
- package/target/lib/file-input/file-input.element.js +5 -6
- package/target/lib/file-input/file-input.element.js.map +1 -1
- package/target/lib/file-input/file-input.element.test.d.ts +1 -0
- package/target/lib/file-input/{file-input.test.js → file-input.element.test.js} +16 -16
- package/target/lib/file-input/file-input.element.test.js.map +1 -0
- package/target/lib/in-page-nav/in-page-nav-item/in-page-nav-item.element.d.ts +2 -3
- package/target/lib/in-page-nav/in-page-nav-item/in-page-nav-item.element.js +15 -13
- package/target/lib/in-page-nav/in-page-nav-item/in-page-nav-item.element.js.map +1 -1
- package/target/lib/in-page-nav/in-page-nav.element.test.d.ts +2 -0
- package/target/lib/in-page-nav/{in-page-nav.test.js → in-page-nav.element.test.js} +6 -6
- package/target/lib/in-page-nav/in-page-nav.element.test.js.map +1 -0
- package/target/lib/input/input.element.d.ts +4 -5
- package/target/lib/input/input.element.js +54 -48
- package/target/lib/input/input.element.js.map +1 -1
- package/target/lib/input/{input.test.js → input.element.test.js} +6 -1
- package/target/lib/input/input.element.test.js.map +1 -0
- package/target/lib/input-mask/input-mask.element.d.ts +1 -1
- package/target/lib/input-mask/input-mask.element.js +1 -1
- package/target/lib/input-mask/input-mask.element.js.map +1 -1
- package/target/lib/input-mask/{input-mask.test.js → input-mask.element.test.js} +1 -1
- package/target/lib/input-mask/input-mask.element.test.js.map +1 -0
- package/target/lib/input-mask/input-mask.stories.js +1 -1
- package/target/lib/input-mask/input-mask.stories.js.map +1 -1
- package/target/lib/link/link.element.d.ts +3 -5
- package/target/lib/link/link.element.js +14 -26
- package/target/lib/link/link.element.js.map +1 -1
- package/target/lib/modal/modal-close/modal-close.element.test.d.ts +1 -0
- package/target/lib/modal/modal-close/modal-close.element.test.js +9 -0
- package/target/lib/modal/modal-close/modal-close.element.test.js.map +1 -0
- package/target/lib/modal/modal-heading/modal-heading.element.test.d.ts +1 -0
- package/target/lib/modal/modal-heading/modal-heading.element.test.js +9 -0
- package/target/lib/modal/modal-heading/modal-heading.element.test.js.map +1 -0
- package/target/lib/modal/modal.element.test.d.ts +3 -0
- package/target/lib/modal/modal.element.test.js +11 -0
- package/target/lib/modal/modal.element.test.js.map +1 -0
- package/target/lib/pagination/pagination-item/pagination-item.element.d.ts +1 -1
- package/target/lib/pagination/pagination-item/pagination-item.element.js +3 -3
- package/target/lib/pagination/pagination-item/pagination-item.element.js.map +1 -1
- package/target/lib/pagination/pagination-no/pagination-no.element.d.ts +2 -3
- package/target/lib/pagination/pagination-no/pagination-no.element.js +10 -8
- package/target/lib/pagination/pagination-no/pagination-no.element.js.map +1 -1
- package/target/lib/pagination/pagination.element.test.d.ts +1 -0
- package/target/lib/pagination/pagination.element.test.js +9 -0
- package/target/lib/pagination/pagination.element.test.js.map +1 -0
- package/target/lib/process-list/process-list.element.test.d.ts +2 -0
- package/target/lib/process-list/{process-list.test.js → process-list.element.test.js} +6 -6
- package/target/lib/process-list/process-list.element.test.js.map +1 -0
- package/target/lib/radio/radio-option/radio-option.element.test.d.ts +2 -0
- package/target/lib/radio/radio-option/radio-option.element.test.js +11 -0
- package/target/lib/radio/radio-option/radio-option.element.test.js.map +1 -0
- package/target/lib/radio/radio.element.test.d.ts +2 -0
- package/target/lib/radio/{radio.test.js → radio.element.test.js} +19 -28
- package/target/lib/radio/radio.element.test.js.map +1 -0
- package/target/lib/range-slider/range-slider.element.d.ts +4 -2
- package/target/lib/range-slider/range-slider.element.js +34 -29
- package/target/lib/range-slider/range-slider.element.js.map +1 -1
- package/target/lib/range-slider/range-slider.element.test.d.ts +1 -0
- package/target/lib/range-slider/range-slider.element.test.js +26 -0
- package/target/lib/range-slider/range-slider.element.test.js.map +1 -0
- package/target/lib/search/search.element.test.d.ts +3 -0
- package/target/lib/search/search.element.test.js +52 -0
- package/target/lib/search/search.element.test.js.map +1 -0
- package/target/lib/select/select.element.d.ts +4 -3
- package/target/lib/select/select.element.js +25 -26
- package/target/lib/select/select.element.js.map +1 -1
- package/target/lib/select/select.element.test.d.ts +2 -0
- package/target/lib/select/{select.test.js → select.element.test.js} +23 -27
- package/target/lib/select/select.element.test.js.map +1 -0
- package/target/lib/services/{icon.service.test.js → icon.service.element.test.js} +1 -1
- package/target/lib/services/icon.service.element.test.js.map +1 -0
- package/target/lib/side-nav/side-nav.element.test.d.ts +3 -0
- package/target/lib/side-nav/{side-nav.test.js → side-nav.element.test.js} +11 -11
- package/target/lib/side-nav/side-nav.element.test.js.map +1 -0
- package/target/lib/step-indicator/step/step.element.d.ts +2 -2
- package/target/lib/step-indicator/step/step.element.js +8 -8
- package/target/lib/step-indicator/step-indicator.element.test.d.ts +2 -0
- package/target/lib/step-indicator/{step-indicator.test.js → step-indicator.element.test.js} +6 -6
- package/target/lib/step-indicator/step-indicator.element.test.js.map +1 -0
- package/target/lib/summary-box/summary-box.element.test.d.ts +1 -0
- package/target/lib/summary-box/summary-box.element.test.js +9 -0
- package/target/lib/summary-box/summary-box.element.test.js.map +1 -0
- package/target/lib/tag/tag.element.test.d.ts +1 -0
- package/target/lib/tag/tag.element.test.js +9 -0
- package/target/lib/tag/tag.element.test.js.map +1 -0
- package/target/lib/textarea/textarea.element.d.ts +2 -2
- package/target/lib/textarea/textarea.element.js +19 -24
- package/target/lib/textarea/textarea.element.js.map +1 -1
- package/target/lib/textarea/textarea.element.test.d.ts +1 -0
- package/target/lib/textarea/{textarea.test.js → textarea.element.test.js} +14 -14
- package/target/lib/textarea/textarea.element.test.js.map +1 -0
- package/src/lib/breadcrumbs/breadcrumbs.test.ts +0 -21
- package/src/lib/button/button.test.ts +0 -17
- package/src/lib/button-group/button-group.test.ts +0 -15
- package/src/lib/collection/collection-item/collection-item.test.ts +0 -15
- package/src/lib/collection/collection.test.ts +0 -15
- package/src/lib/config/config.test.ts +0 -15
- package/src/lib/description/description.test.ts +0 -15
- package/src/lib/file-input/file-input-preview/file-input-preview.test.ts +0 -95
- package/src/lib/file-input/file-input.test.ts +0 -79
- package/src/lib/modal/modal-close/modal-close.test.ts +0 -15
- package/src/lib/modal/modal-heading/modal-heading.test.ts +0 -15
- package/src/lib/modal/modal.test.ts +0 -25
- package/src/lib/pagination/pagination.test.ts +0 -15
- package/src/lib/radio/radio-option/radio-option.test.ts +0 -20
- package/src/lib/radio/radio.test.ts +0 -174
- package/src/lib/range-slider/range-slider.test.ts +0 -52
- package/src/lib/search/search.test.ts +0 -81
- package/src/lib/summary-box/summary-box.test.ts +0 -15
- package/src/lib/tag/tag.test.ts +0 -15
- package/target/lib/accordion/accordion.test.d.ts +0 -1
- package/target/lib/accordion/accordion.test.js.map +0 -1
- package/target/lib/alert/alert.test.d.ts +0 -1
- package/target/lib/alert/alert.test.js.map +0 -1
- package/target/lib/breadcrumbs/breadcrumbs.test.d.ts +0 -2
- package/target/lib/breadcrumbs/breadcrumbs.test.js.map +0 -1
- package/target/lib/button/button.test.d.ts +0 -1
- package/target/lib/button/button.test.js +0 -12
- package/target/lib/button/button.test.js.map +0 -1
- package/target/lib/button-group/button-group.test.d.ts +0 -1
- package/target/lib/button-group/button-group.test.js +0 -9
- package/target/lib/button-group/button-group.test.js.map +0 -1
- package/target/lib/card/card.test.d.ts +0 -6
- package/target/lib/card/card.test.js.map +0 -1
- package/target/lib/checkbox/checkbox.test.d.ts +0 -1
- package/target/lib/checkbox/checkbox.test.js.map +0 -1
- package/target/lib/collection/collection-item/collection-item.test.d.ts +0 -1
- package/target/lib/collection/collection-item/collection-item.test.js +0 -9
- package/target/lib/collection/collection-item/collection-item.test.js.map +0 -1
- package/target/lib/collection/collection.test.d.ts +0 -1
- package/target/lib/collection/collection.test.js +0 -9
- package/target/lib/collection/collection.test.js.map +0 -1
- package/target/lib/combo-box/combo-box.test.d.ts +0 -3
- package/target/lib/combo-box/combo-box.test.js.map +0 -1
- package/target/lib/config/config.test.d.ts +0 -1
- package/target/lib/config/config.test.js +0 -9
- package/target/lib/config/config.test.js.map +0 -1
- package/target/lib/description/description.test.d.ts +0 -1
- package/target/lib/description/description.test.js +0 -9
- package/target/lib/description/description.test.js.map +0 -1
- package/target/lib/file-input/file-input-preview/file-input-preview.test.d.ts +0 -2
- package/target/lib/file-input/file-input-preview/file-input-preview.test.js.map +0 -1
- package/target/lib/file-input/file-input.test.d.ts +0 -1
- package/target/lib/file-input/file-input.test.js.map +0 -1
- package/target/lib/in-page-nav/in-page-nav.test.d.ts +0 -2
- package/target/lib/in-page-nav/in-page-nav.test.js.map +0 -1
- package/target/lib/input/input.test.js.map +0 -1
- package/target/lib/input-mask/input-mask.test.js.map +0 -1
- package/target/lib/modal/modal-close/modal-close.test.d.ts +0 -1
- package/target/lib/modal/modal-close/modal-close.test.js +0 -9
- package/target/lib/modal/modal-close/modal-close.test.js.map +0 -1
- package/target/lib/modal/modal-heading/modal-heading.test.d.ts +0 -1
- package/target/lib/modal/modal-heading/modal-heading.test.js +0 -9
- package/target/lib/modal/modal-heading/modal-heading.test.js.map +0 -1
- package/target/lib/modal/modal.test.d.ts +0 -3
- package/target/lib/modal/modal.test.js +0 -11
- package/target/lib/modal/modal.test.js.map +0 -1
- package/target/lib/pagination/pagination.test.d.ts +0 -1
- package/target/lib/pagination/pagination.test.js +0 -9
- package/target/lib/pagination/pagination.test.js.map +0 -1
- package/target/lib/process-list/process-list.test.d.ts +0 -2
- package/target/lib/process-list/process-list.test.js.map +0 -1
- package/target/lib/radio/radio-option/radio-option.test.d.ts +0 -2
- package/target/lib/radio/radio-option/radio-option.test.js +0 -11
- package/target/lib/radio/radio-option/radio-option.test.js.map +0 -1
- package/target/lib/radio/radio.test.d.ts +0 -2
- package/target/lib/radio/radio.test.js.map +0 -1
- package/target/lib/range-slider/range-slider.test.d.ts +0 -1
- package/target/lib/range-slider/range-slider.test.js +0 -25
- package/target/lib/range-slider/range-slider.test.js.map +0 -1
- package/target/lib/search/search.test.d.ts +0 -3
- package/target/lib/search/search.test.js +0 -52
- package/target/lib/search/search.test.js.map +0 -1
- package/target/lib/select/select.test.d.ts +0 -2
- package/target/lib/select/select.test.js.map +0 -1
- package/target/lib/services/icon.service.test.js.map +0 -1
- package/target/lib/side-nav/side-nav.test.d.ts +0 -3
- package/target/lib/side-nav/side-nav.test.js.map +0 -1
- package/target/lib/step-indicator/step-indicator.test.d.ts +0 -2
- package/target/lib/step-indicator/step-indicator.test.js.map +0 -1
- package/target/lib/summary-box/summary-box.test.d.ts +0 -1
- package/target/lib/summary-box/summary-box.test.js +0 -9
- package/target/lib/summary-box/summary-box.test.js.map +0 -1
- package/target/lib/tag/tag.test.d.ts +0 -1
- package/target/lib/tag/tag.test.js +0 -9
- package/target/lib/tag/tag.test.js.map +0 -1
- package/target/lib/textarea/textarea.test.d.ts +0 -1
- package/target/lib/textarea/textarea.test.js.map +0 -1
- /package/src/lib/input-mask/{input-mask.test.ts → input-mask.element.test.ts} +0 -0
- /package/src/lib/services/{icon.service.test.ts → icon.service.element.test.ts} +0 -0
- /package/target/lib/input/{input.test.d.ts → input.element.test.d.ts} +0 -0
- /package/target/lib/input-mask/{input-mask.test.d.ts → input-mask.element.test.d.ts} +0 -0
- /package/target/lib/services/{icon.service.test.d.ts → icon.service.element.test.d.ts} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './checkbox.element.js';
|
|
2
2
|
|
|
3
|
-
import { assert, fixture, html } from
|
|
3
|
+
import { assert, fixture, html } from '@open-wc/testing';
|
|
4
4
|
|
|
5
|
-
describe(
|
|
6
|
-
it(
|
|
5
|
+
describe('usa-checkbox', () => {
|
|
6
|
+
it('should be accessible', async () => {
|
|
7
7
|
const form = await fixture<HTMLFormElement>(html`
|
|
8
8
|
<usa-checkbox name="fname" value="Foo">Hello World</usa-checkbox>
|
|
9
9
|
`);
|
|
@@ -11,12 +11,10 @@ describe("usa-checkbox", () => {
|
|
|
11
11
|
return assert.isAccessible(form);
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
it(
|
|
14
|
+
it('should submit form with default values', async () => {
|
|
15
15
|
const form = await fixture<HTMLFormElement>(html`
|
|
16
16
|
<form>
|
|
17
|
-
<usa-checkbox name="enabled" value="test" checked>
|
|
18
|
-
Hello World
|
|
19
|
-
</usa-checkbox>
|
|
17
|
+
<usa-checkbox name="enabled" value="test" checked> Hello World </usa-checkbox>
|
|
20
18
|
|
|
21
19
|
<button>Submit</button>
|
|
22
20
|
</form>
|
|
@@ -24,10 +22,10 @@ describe("usa-checkbox", () => {
|
|
|
24
22
|
|
|
25
23
|
const value = new FormData(form);
|
|
26
24
|
|
|
27
|
-
assert.equal(value.get(
|
|
25
|
+
assert.equal(value.get('enabled'), 'test');
|
|
28
26
|
});
|
|
29
27
|
|
|
30
|
-
it(
|
|
28
|
+
it('should update form value as input value changed', async () => {
|
|
31
29
|
const form = await fixture<HTMLFormElement>(html`
|
|
32
30
|
<form>
|
|
33
31
|
<usa-checkbox name="enabled" value="test">Hello World</usa-checkbox>
|
|
@@ -36,24 +34,24 @@ describe("usa-checkbox", () => {
|
|
|
36
34
|
</form>
|
|
37
35
|
`);
|
|
38
36
|
|
|
39
|
-
const checkbox = form.querySelector(
|
|
40
|
-
const nativeInput = checkbox?.shadowRoot?.querySelector(
|
|
37
|
+
const checkbox = form.querySelector('usa-checkbox');
|
|
38
|
+
const nativeInput = checkbox?.shadowRoot?.querySelector('input');
|
|
41
39
|
|
|
42
40
|
if (nativeInput) {
|
|
43
41
|
nativeInput.click();
|
|
44
42
|
}
|
|
45
43
|
|
|
44
|
+
await Promise.resolve();
|
|
45
|
+
|
|
46
46
|
const value = new FormData(form);
|
|
47
47
|
|
|
48
|
-
assert.equal(value.get(
|
|
48
|
+
assert.equal(value.get('enabled'), 'test');
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
it(
|
|
51
|
+
it('should not submit when not valid', async () => {
|
|
52
52
|
const form = await fixture<HTMLFormElement>(html`
|
|
53
53
|
<form>
|
|
54
|
-
<usa-checkbox name="enabled" value="test" required>
|
|
55
|
-
Hello World
|
|
56
|
-
</usa-checkbox>
|
|
54
|
+
<usa-checkbox name="enabled" value="test" required> Hello World </usa-checkbox>
|
|
57
55
|
|
|
58
56
|
<button>Submit</button>
|
|
59
57
|
</form>
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '@joist/templating/define.js';
|
|
2
|
+
|
|
3
|
+
import { attr, css, element, html, listen, query } from '@joist/element';
|
|
4
|
+
import { bind } from '@joist/templating';
|
|
5
|
+
import { effect } from '@joist/observable';
|
|
2
6
|
|
|
3
7
|
declare global {
|
|
4
8
|
interface HTMLElementTagNameMap {
|
|
5
|
-
|
|
9
|
+
'usa-checkbox': USACheckboxElement;
|
|
6
10
|
}
|
|
7
11
|
}
|
|
8
12
|
|
|
9
13
|
@element({
|
|
10
|
-
tagName:
|
|
14
|
+
tagName: 'usa-checkbox',
|
|
11
15
|
shadowDom: [
|
|
12
16
|
css`
|
|
13
17
|
* {
|
|
@@ -69,9 +73,9 @@ declare global {
|
|
|
69
73
|
background-color: #005ea2;
|
|
70
74
|
box-shadow: 0 0 0 2px #005ea2;
|
|
71
75
|
}
|
|
72
|
-
|
|
76
|
+
|
|
73
77
|
input:checked + .checkbox::after {
|
|
74
|
-
content:
|
|
78
|
+
content: ' ';
|
|
75
79
|
display: block;
|
|
76
80
|
height: 1rem;
|
|
77
81
|
width: 0.5rem;
|
|
@@ -112,14 +116,14 @@ declare global {
|
|
|
112
116
|
`,
|
|
113
117
|
html`
|
|
114
118
|
<label>
|
|
115
|
-
<
|
|
116
|
-
|
|
117
|
-
|
|
119
|
+
<j-bind props="checked,required,disabled" target="input">
|
|
120
|
+
<input type="checkbox" tabindex="0" />
|
|
121
|
+
<div class="checkbox" part="checkbox"></div>
|
|
122
|
+
</j-bind>
|
|
118
123
|
|
|
119
124
|
<div class="title" part="title">
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
</j-props>
|
|
125
|
+
<slot></slot>
|
|
126
|
+
</div>
|
|
123
127
|
</label>
|
|
124
128
|
`,
|
|
125
129
|
],
|
|
@@ -128,18 +132,23 @@ export class USACheckboxElement extends HTMLElement {
|
|
|
128
132
|
static formAssociated = true;
|
|
129
133
|
|
|
130
134
|
@attr()
|
|
135
|
+
@bind()
|
|
131
136
|
accessor checked = false;
|
|
132
137
|
|
|
133
138
|
@attr()
|
|
134
|
-
|
|
139
|
+
@bind()
|
|
140
|
+
accessor name = '';
|
|
135
141
|
|
|
136
142
|
@attr()
|
|
137
|
-
|
|
143
|
+
@bind()
|
|
144
|
+
accessor value = '';
|
|
138
145
|
|
|
139
146
|
@attr()
|
|
147
|
+
@bind()
|
|
140
148
|
accessor required = false;
|
|
141
149
|
|
|
142
150
|
@attr()
|
|
151
|
+
@bind()
|
|
143
152
|
accessor disabled = false;
|
|
144
153
|
|
|
145
154
|
@attr({
|
|
@@ -147,41 +156,28 @@ export class USACheckboxElement extends HTMLElement {
|
|
|
147
156
|
})
|
|
148
157
|
accessor tiled = false;
|
|
149
158
|
|
|
150
|
-
#checkbox = query(
|
|
151
|
-
|
|
159
|
+
#checkbox = query('input');
|
|
152
160
|
#internals = this.attachInternals();
|
|
153
161
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
checked: this.checked,
|
|
157
|
-
name: this.name,
|
|
158
|
-
disabled: this.disabled,
|
|
159
|
-
required: this.required,
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
+
@effect()
|
|
163
|
+
onChange() {
|
|
162
164
|
this.#syncFormState();
|
|
163
165
|
}
|
|
164
166
|
|
|
165
|
-
@listen(
|
|
167
|
+
@listen('change', 'input[type=checkbox]')
|
|
166
168
|
onCheckboxChange() {
|
|
167
169
|
const checkbox = this.#checkbox();
|
|
168
170
|
this.checked = checkbox.checked;
|
|
169
|
-
|
|
170
|
-
this.#syncFormState();
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
#syncFormState() {
|
|
174
174
|
const checkbox = this.#checkbox();
|
|
175
175
|
|
|
176
176
|
this.#internals.setValidity({});
|
|
177
|
-
this.#internals.setFormValue(
|
|
177
|
+
this.#internals.setFormValue(this.checked ? this.value : null);
|
|
178
178
|
|
|
179
179
|
if (checkbox.validationMessage) {
|
|
180
|
-
this.#internals.setValidity(
|
|
181
|
-
{ customError: true },
|
|
182
|
-
checkbox.validationMessage,
|
|
183
|
-
checkbox,
|
|
184
|
-
);
|
|
180
|
+
this.#internals.setValidity({ customError: true }, checkbox.validationMessage, checkbox);
|
|
185
181
|
}
|
|
186
182
|
}
|
|
187
183
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from
|
|
2
|
-
import { html } from
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/web-components';
|
|
2
|
+
import { html } from 'lit';
|
|
3
3
|
|
|
4
|
-
import type { USACheckboxElement } from
|
|
4
|
+
import type { USACheckboxElement } from './checkbox.element.js';
|
|
5
5
|
|
|
6
6
|
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
7
7
|
const meta = {
|
|
8
|
-
title:
|
|
9
|
-
tags: [
|
|
8
|
+
title: 'usa-checkbox',
|
|
9
|
+
tags: ['autodocs'],
|
|
10
10
|
argTypes: {},
|
|
11
11
|
args: {},
|
|
12
12
|
} satisfies Meta<USACheckboxElement & { description: string }>;
|
|
@@ -19,15 +19,15 @@ type Story = StoryObj<USACheckboxElement>;
|
|
|
19
19
|
export const Primary: Story = {
|
|
20
20
|
render(args) {
|
|
21
21
|
return html`
|
|
22
|
-
<usa-checkbox name="${args.name}" value="${args.value}"
|
|
22
|
+
<usa-checkbox name="${args.name}" value="${args.value}" required>
|
|
23
23
|
I agree to the above terms and conditions
|
|
24
24
|
</usa-checkbox>
|
|
25
25
|
`;
|
|
26
26
|
},
|
|
27
27
|
args: {
|
|
28
28
|
checked: false,
|
|
29
|
-
name:
|
|
30
|
-
value:
|
|
29
|
+
name: 'toc',
|
|
30
|
+
value: 'agree',
|
|
31
31
|
disabled: false,
|
|
32
32
|
required: false,
|
|
33
33
|
},
|
|
@@ -39,21 +39,10 @@ export const Group: Story = {
|
|
|
39
39
|
<usa-checkbox-group>
|
|
40
40
|
<legend>Select any historical figure</legend>
|
|
41
41
|
|
|
42
|
-
<usa-checkbox name="historical-figure" value="sojurner-truth">
|
|
43
|
-
|
|
44
|
-
</usa-checkbox>
|
|
45
|
-
|
|
46
|
-
<usa-checkbox name="historical-figure" value="frederick-douglass">
|
|
47
|
-
Frederick Douglass
|
|
48
|
-
</usa-checkbox>
|
|
49
|
-
|
|
50
|
-
<usa-checkbox name="historical-figure" value="booker-t-washington">
|
|
51
|
-
Booker T. Washington
|
|
52
|
-
</usa-checkbox>
|
|
53
|
-
|
|
54
|
-
<usa-checkbox name="historical-figure" value="gw-carver" disabled>
|
|
55
|
-
George Washington Carver
|
|
56
|
-
</usa-checkbox>
|
|
42
|
+
<usa-checkbox name="historical-figure" value="sojurner-truth">Sojourner Truth</usa-checkbox>
|
|
43
|
+
<usa-checkbox name="historical-figure" value="frederick-douglass">Frederick Douglass </usa-checkbox>
|
|
44
|
+
<usa-checkbox name="historical-figure" value="booker-t-washington">Booker T. Washington</usa-checkbox>
|
|
45
|
+
<usa-checkbox name="historical-figure" value="gw-carver" disabled>George Washington Carver</usa-checkbox>
|
|
57
46
|
</usa-checkbox-group>
|
|
58
47
|
`;
|
|
59
48
|
},
|
|
@@ -67,17 +56,12 @@ export const Tiled: Story = {
|
|
|
67
56
|
|
|
68
57
|
<usa-checkbox name="historical-figure" value="sojurner-truth" tiled>
|
|
69
58
|
Sojourner Truth
|
|
70
|
-
<usa-description>
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<usa-checkbox name="historical-figure" value="frederick-douglass" tiled>
|
|
74
|
-
Frederick Douglass
|
|
59
|
+
<usa-description>
|
|
60
|
+
This is optional text that can be used to describe the label in more detail.
|
|
61
|
+
</usa-description>
|
|
75
62
|
</usa-checkbox>
|
|
76
|
-
|
|
77
|
-
<usa-checkbox name="historical-figure" value="booker-t-washington" tiled>
|
|
78
|
-
Booker T. Washington
|
|
79
|
-
</usa-checkbox>
|
|
80
|
-
|
|
63
|
+
<usa-checkbox name="historical-figure" value="frederick-douglass" tiled> Frederick Douglass </usa-checkbox>
|
|
64
|
+
<usa-checkbox name="historical-figure" value="booker-t-washington" tiled> Booker T. Washington </usa-checkbox>
|
|
81
65
|
<usa-checkbox name="historical-figure" value="gw-carver" tiled disabled>
|
|
82
66
|
George Washington Carver
|
|
83
67
|
</usa-checkbox>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import './collection-item.element.js';
|
|
2
|
+
|
|
3
|
+
import { assert, fixture, html } from '@open-wc/testing';
|
|
4
|
+
|
|
5
|
+
import type { USACollectionItemElement } from './collection-item.element.js';
|
|
6
|
+
|
|
7
|
+
describe('usa-collection-item', () => {
|
|
8
|
+
it('should be accessible', async () => {
|
|
9
|
+
const collectionItem = await fixture<USACollectionItemElement>(html`
|
|
10
|
+
<usa-collection-item>Hello World</usa-collection-item>
|
|
11
|
+
`);
|
|
12
|
+
|
|
13
|
+
return assert.isAccessible(collectionItem);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import './collection.element.js';
|
|
2
|
+
|
|
3
|
+
import { assert, fixture, html } from '@open-wc/testing';
|
|
4
|
+
|
|
5
|
+
import type { USACollectionElement } from './collection.element.js';
|
|
6
|
+
|
|
7
|
+
describe('usa-collection', () => {
|
|
8
|
+
it('should be accessible', async () => {
|
|
9
|
+
const collection = await fixture<USACollectionElement>(html` <usa-collection>Hello World</usa-collection> `);
|
|
10
|
+
|
|
11
|
+
return assert.isAccessible(collection);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import './combo-box.element.js';
|
|
2
|
+
import './combo-box-option/combo-box-option.element.js';
|
|
3
|
+
import '../input/input.element.js';
|
|
4
4
|
|
|
5
|
-
import { assert, fixture, html } from
|
|
5
|
+
import { assert, fixture, html } from '@open-wc/testing';
|
|
6
6
|
|
|
7
|
-
import type { USAComboBoxElement } from
|
|
7
|
+
import type { USAComboBoxElement } from './combo-box.element.js';
|
|
8
8
|
|
|
9
|
-
describe(
|
|
9
|
+
describe('usa-combo-box', () => {
|
|
10
10
|
let autocomplete: USAComboBoxElement;
|
|
11
11
|
let input: HTMLInputElement;
|
|
12
12
|
|
|
@@ -25,123 +25,94 @@ describe("usa-combo-box", () => {
|
|
|
25
25
|
input = autocomplete.input();
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
it(
|
|
29
|
-
input.value =
|
|
30
|
-
input.dispatchEvent(new Event(
|
|
28
|
+
it('should filter items based on input', async () => {
|
|
29
|
+
input.value = 'b';
|
|
30
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
31
31
|
|
|
32
32
|
const suggestions = autocomplete.listItems();
|
|
33
33
|
|
|
34
34
|
assert.equal(suggestions.length, 2);
|
|
35
|
-
assert.equal(suggestions[0].dataset.value,
|
|
36
|
-
assert.equal(suggestions[1].dataset.value,
|
|
35
|
+
assert.equal(suggestions[0].dataset.value, 'Banana');
|
|
36
|
+
assert.equal(suggestions[1].dataset.value, 'Blueberry');
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
it(
|
|
40
|
-
input.value =
|
|
41
|
-
input.dispatchEvent(new Event(
|
|
39
|
+
it('should show all suggestions when input is empty', async () => {
|
|
40
|
+
input.value = '';
|
|
41
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
42
42
|
|
|
43
43
|
const suggestions = autocomplete.listItems();
|
|
44
44
|
assert.equal(suggestions.length, 4);
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
it(
|
|
48
|
-
input.value =
|
|
49
|
-
input.dispatchEvent(new Event(
|
|
47
|
+
it('should handle case-insensitive search', async () => {
|
|
48
|
+
input.value = 'B';
|
|
49
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
50
50
|
|
|
51
51
|
const suggestions = autocomplete.listItems();
|
|
52
52
|
assert.equal(suggestions.length, 2);
|
|
53
|
-
assert.equal(suggestions[0].dataset.value,
|
|
54
|
-
assert.equal(suggestions[1].dataset.value,
|
|
53
|
+
assert.equal(suggestions[0].dataset.value, 'Banana');
|
|
54
|
+
assert.equal(suggestions[1].dataset.value, 'Blueberry');
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
it(
|
|
57
|
+
it('should navigate suggestions with arrow keys', async () => {
|
|
58
58
|
// select item from list
|
|
59
|
-
input.value =
|
|
60
|
-
input.dispatchEvent(new Event(
|
|
59
|
+
input.value = 'b';
|
|
60
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
61
61
|
|
|
62
62
|
// Arrow down
|
|
63
|
-
input.dispatchEvent(
|
|
64
|
-
|
|
65
|
-
);
|
|
66
|
-
assert.equal(
|
|
67
|
-
autocomplete.currentItemEl?.getAttribute("data-value"),
|
|
68
|
-
"Banana",
|
|
69
|
-
);
|
|
63
|
+
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', bubbles: true }));
|
|
64
|
+
assert.equal(autocomplete.currentItemEl?.getAttribute('data-value'), 'Banana');
|
|
70
65
|
|
|
71
66
|
// Arrow down again
|
|
72
|
-
input.dispatchEvent(
|
|
73
|
-
|
|
74
|
-
);
|
|
75
|
-
assert.equal(
|
|
76
|
-
autocomplete.currentItemEl?.getAttribute("data-value"),
|
|
77
|
-
"Blueberry",
|
|
78
|
-
);
|
|
67
|
+
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', bubbles: true }));
|
|
68
|
+
assert.equal(autocomplete.currentItemEl?.getAttribute('data-value'), 'Blueberry');
|
|
79
69
|
});
|
|
80
70
|
|
|
81
|
-
it(
|
|
82
|
-
input.value =
|
|
83
|
-
input.dispatchEvent(new Event(
|
|
71
|
+
it('should select suggestion with enter key', async () => {
|
|
72
|
+
input.value = 'b';
|
|
73
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
84
74
|
|
|
85
75
|
// Navigate to first suggestion
|
|
86
|
-
input.dispatchEvent(
|
|
87
|
-
new KeyboardEvent("keydown", { key: "ArrowDown", bubbles: true }),
|
|
88
|
-
);
|
|
76
|
+
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', bubbles: true }));
|
|
89
77
|
|
|
90
78
|
// Select suggestion
|
|
91
79
|
const firstSuggestion = autocomplete.listItems()[0];
|
|
92
80
|
|
|
93
|
-
firstSuggestion?.dispatchEvent(
|
|
94
|
-
new KeyboardEvent("keydown", { key: "Enter", bubbles: true }),
|
|
95
|
-
);
|
|
81
|
+
firstSuggestion?.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }));
|
|
96
82
|
|
|
97
|
-
assert.equal(input.value,
|
|
98
|
-
assert.equal(autocomplete.list().innerHTML,
|
|
83
|
+
assert.equal(input.value, 'Banana');
|
|
84
|
+
assert.equal(autocomplete.list().innerHTML, '');
|
|
99
85
|
});
|
|
100
86
|
|
|
101
|
-
it(
|
|
102
|
-
input.value =
|
|
103
|
-
input.dispatchEvent(new Event(
|
|
87
|
+
it('should focus back on the input if no other items', async () => {
|
|
88
|
+
input.value = 'b';
|
|
89
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
104
90
|
|
|
105
|
-
input.dispatchEvent(
|
|
106
|
-
new KeyboardEvent("keydown", { key: "ArrowDown", bubbles: true }),
|
|
107
|
-
);
|
|
91
|
+
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', bubbles: true }));
|
|
108
92
|
|
|
109
93
|
// Try to go up from first suggestion
|
|
110
|
-
input.dispatchEvent(
|
|
111
|
-
new KeyboardEvent("keydown", { key: "ArrowUp", bubbles: true }),
|
|
112
|
-
);
|
|
94
|
+
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowUp', bubbles: true }));
|
|
113
95
|
|
|
114
96
|
assert.equal(autocomplete.currentItemEl, null);
|
|
115
97
|
});
|
|
116
98
|
|
|
117
|
-
it(
|
|
118
|
-
input.value =
|
|
119
|
-
input.dispatchEvent(new Event(
|
|
99
|
+
it('should not go below last suggestion with arrow down', async () => {
|
|
100
|
+
input.value = 'b';
|
|
101
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
120
102
|
|
|
121
103
|
// Navigate to last suggestion
|
|
122
|
-
input.dispatchEvent(
|
|
123
|
-
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
input.dispatchEvent(
|
|
127
|
-
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
new KeyboardEvent("keydown", { key: "ArrowDown", bubbles: true }),
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
input.dispatchEvent(
|
|
135
|
-
new KeyboardEvent("keydown", { key: "ArrowDown", bubbles: true }),
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
assert.equal(
|
|
139
|
-
autocomplete.currentItemEl?.getAttribute("data-value"),
|
|
140
|
-
"Blueberry",
|
|
141
|
-
);
|
|
104
|
+
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', bubbles: true }));
|
|
105
|
+
|
|
106
|
+
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', bubbles: true }));
|
|
107
|
+
|
|
108
|
+
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', bubbles: true }));
|
|
109
|
+
|
|
110
|
+
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', bubbles: true }));
|
|
111
|
+
|
|
112
|
+
assert.equal(autocomplete.currentItemEl?.getAttribute('data-value'), 'Blueberry');
|
|
142
113
|
});
|
|
143
114
|
|
|
144
|
-
it(
|
|
115
|
+
it('should submit form with default values', async () => {
|
|
145
116
|
const form = await fixture<HTMLFormElement>(html`
|
|
146
117
|
<form>
|
|
147
118
|
<usa-combo-box name="search" value="Apple" placeholder="Select a fruit">
|
|
@@ -158,10 +129,10 @@ describe("usa-combo-box", () => {
|
|
|
158
129
|
`);
|
|
159
130
|
|
|
160
131
|
const value = new FormData(form);
|
|
161
|
-
assert.equal(value.get(
|
|
132
|
+
assert.equal(value.get('search'), 'Apple');
|
|
162
133
|
});
|
|
163
134
|
|
|
164
|
-
it(
|
|
135
|
+
it('should update form value when an option is selected', async () => {
|
|
165
136
|
const form = await fixture<HTMLFormElement>(html`
|
|
166
137
|
<form>
|
|
167
138
|
<usa-combo-box name="search" placeholder="Select a fruit">
|
|
@@ -177,35 +148,35 @@ describe("usa-combo-box", () => {
|
|
|
177
148
|
</form>
|
|
178
149
|
`);
|
|
179
150
|
|
|
180
|
-
const comboBox = form.querySelector(
|
|
151
|
+
const comboBox = form.querySelector('usa-combo-box');
|
|
181
152
|
|
|
182
153
|
if (!comboBox) {
|
|
183
|
-
throw new Error(
|
|
154
|
+
throw new Error('Combo box not found');
|
|
184
155
|
}
|
|
185
156
|
|
|
186
|
-
const input = comboBox.shadowRoot?.querySelector(
|
|
157
|
+
const input = comboBox.shadowRoot?.querySelector('input');
|
|
187
158
|
|
|
188
159
|
if (!input) {
|
|
189
|
-
throw new Error(
|
|
160
|
+
throw new Error('input not found');
|
|
190
161
|
}
|
|
191
162
|
|
|
192
163
|
// Type to show suggestions
|
|
193
|
-
input.value =
|
|
194
|
-
input.dispatchEvent(new Event(
|
|
164
|
+
input.value = 'Ban';
|
|
165
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
195
166
|
|
|
196
167
|
// Select the first suggestion
|
|
197
168
|
const suggestions = comboBox.listItems();
|
|
198
169
|
|
|
199
170
|
suggestions[0]
|
|
200
|
-
.querySelector(
|
|
171
|
+
.querySelector('slot')
|
|
201
172
|
?.assignedElements()[0]
|
|
202
|
-
.dispatchEvent(new MouseEvent(
|
|
173
|
+
.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
203
174
|
|
|
204
175
|
const value = new FormData(form);
|
|
205
|
-
assert.equal(value.get(
|
|
176
|
+
assert.equal(value.get('search'), 'Banana');
|
|
206
177
|
});
|
|
207
178
|
|
|
208
|
-
it(
|
|
179
|
+
it('should not submit when required and no value is selected', async () => {
|
|
209
180
|
const form = await fixture<HTMLFormElement>(html`
|
|
210
181
|
<form>
|
|
211
182
|
<usa-combo-box name="search" required placeholder="Select a fruit">
|
|
@@ -224,7 +195,7 @@ describe("usa-combo-box", () => {
|
|
|
224
195
|
assert.equal(form.checkValidity(), false);
|
|
225
196
|
});
|
|
226
197
|
|
|
227
|
-
it(
|
|
198
|
+
it('should not show suggestions when disabled', async () => {
|
|
228
199
|
const disabledComboBox = await fixture<USAComboBoxElement>(html`
|
|
229
200
|
<usa-combo-box name="search" disabled placeholder="Select a fruit">
|
|
230
201
|
<span slot="label">Fruits</span>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import './config.element.js';
|
|
2
|
+
|
|
3
|
+
import { assert, fixture, html } from '@open-wc/testing';
|
|
4
|
+
|
|
5
|
+
import type { USAConfigElement } from './config.element.js';
|
|
6
|
+
|
|
7
|
+
describe('usa-config', () => {
|
|
8
|
+
it('should be accessible', async () => {
|
|
9
|
+
const config = await fixture<USAConfigElement>(html` <usa-config>Hello World</usa-config> `);
|
|
10
|
+
|
|
11
|
+
return assert.isAccessible(config);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import './description.element.js';
|
|
2
|
+
|
|
3
|
+
import { assert, fixture, html } from '@open-wc/testing';
|
|
4
|
+
|
|
5
|
+
import type { USADescriptionElement } from './description.element.js';
|
|
6
|
+
|
|
7
|
+
describe('usa-description', () => {
|
|
8
|
+
it('should be accessible', async () => {
|
|
9
|
+
const description = await fixture<USADescriptionElement>(html` <usa-description>Hello World</usa-description> `);
|
|
10
|
+
|
|
11
|
+
return assert.isAccessible(description);
|
|
12
|
+
});
|
|
13
|
+
});
|