@api-client/ui 0.5.39 → 0.5.41
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/build/src/elements/contextual-menu/{internals/ContextualMenu.d.ts → ContextualMenu.d.ts} +11 -6
- package/build/src/elements/contextual-menu/ContextualMenu.d.ts.map +1 -0
- package/build/src/elements/contextual-menu/{internals/ContextualMenu.js → ContextualMenu.js} +25 -3
- package/build/src/elements/contextual-menu/ContextualMenu.js.map +1 -0
- package/build/src/elements/contextual-menu/internals/types.d.ts +16 -7
- package/build/src/elements/contextual-menu/internals/types.d.ts.map +1 -1
- package/build/src/elements/contextual-menu/internals/types.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
- package/src/elements/contextual-menu/{internals/ContextualMenu.ts → ContextualMenu.ts} +31 -7
- package/src/elements/contextual-menu/internals/types.ts +17 -7
- package/.aiexclude +0 -3
- package/.cursor/rules/html-and-css-best-practices.mdc +0 -63
- package/.cursor/rules/lit-best-practices.mdc +0 -89
- package/.editorconfig +0 -29
- package/.github/CONTRIBUTING.md +0 -24
- package/.github/instructions/html-and-css-best-practices.instructions.md +0 -70
- package/.github/instructions/lit-best-practices.instructions.md +0 -90
- package/.github/release.yml +0 -14
- package/.github/stale.yml +0 -23
- package/.github/workflows/auto-release.yml +0 -182
- package/.github/workflows/release.yml +0 -82
- package/.prettierrc.js +0 -14
- package/.vscode/settings.json +0 -18
- package/RELEASE.md +0 -163
- package/RELEASE_SETUP.md +0 -235
- package/build/src/demo/DemoPage.d.ts +0 -81
- package/build/src/demo/DemoPage.d.ts.map +0 -1
- package/build/src/demo/DemoPage.js +0 -175
- package/build/src/demo/DemoPage.js.map +0 -1
- package/build/src/demo/DemoStyles.d.ts +0 -3
- package/build/src/demo/DemoStyles.d.ts.map +0 -1
- package/build/src/demo/DemoStyles.js +0 -60
- package/build/src/demo/DemoStyles.js.map +0 -1
- package/build/src/elements/contextual-menu/internals/ContextualMenu.d.ts.map +0 -1
- package/build/src/elements/contextual-menu/internals/ContextualMenu.js.map +0 -1
- package/build/test/elements/navigation/Navigation.test.d.ts +0 -3
- package/build/test/elements/navigation/Navigation.test.d.ts.map +0 -1
- package/build/test/elements/navigation/Navigation.test.js +0 -113
- package/build/test/elements/navigation/Navigation.test.js.map +0 -1
- package/commitlint.config.cjs +0 -2
- package/demo/elements/authorization/AuthPlugin.js +0 -57
- package/demo/elements/authorization/AuthProxy.js +0 -215
- package/demo/elements/authorization/api-key.html +0 -27
- package/demo/elements/authorization/api-key.ts +0 -44
- package/demo/elements/authorization/basic.html +0 -27
- package/demo/elements/authorization/basic.ts +0 -43
- package/demo/elements/authorization/bearer.html +0 -27
- package/demo/elements/authorization/bearer.ts +0 -43
- package/demo/elements/authorization/env.js +0 -8
- package/demo/elements/authorization/index.html +0 -44
- package/demo/elements/authorization/ntlm.html +0 -27
- package/demo/elements/authorization/ntlm.ts +0 -43
- package/demo/elements/authorization/oauth-authorize.html +0 -75
- package/demo/elements/authorization/oauth-authorize.ts +0 -40
- package/demo/elements/authorization/oauth-error.html +0 -18
- package/demo/elements/authorization/oauth-error.ts +0 -10
- package/demo/elements/authorization/oauth-popup.html +0 -36
- package/demo/elements/authorization/oauth2.html +0 -27
- package/demo/elements/authorization/oauth2.ts +0 -100
- package/demo/elements/authorization/oidc.html +0 -27
- package/demo/elements/authorization/oidc.ts +0 -139
- package/demo/elements/authorization/private.crt +0 -31
- package/demo/elements/authorization/private.csr +0 -28
- package/demo/elements/authorization/private.key +0 -51
- package/demo/elements/authorization/private.pem +0 -31
- package/demo/elements/authorization/redirect.html +0 -20
- package/demo/elements/authorization/ssl-commands.sh +0 -30
- package/demo/elements/authorization/ssl.conf +0 -24
- package/demo/elements/autocomplete/index.html +0 -64
- package/demo/elements/autocomplete/index.ts +0 -171
- package/demo/elements/code-editor/CodeEditorDemo.ts +0 -173
- package/demo/elements/code-editor/index.html +0 -19
- package/demo/elements/context-menu/DemoIcons.ts +0 -21
- package/demo/elements/context-menu/basic.html +0 -25
- package/demo/elements/context-menu/basic.ts +0 -119
- package/demo/elements/context-menu/custom-data.html +0 -25
- package/demo/elements/context-menu/custom-data.ts +0 -62
- package/demo/elements/context-menu/demo.css +0 -28
- package/demo/elements/context-menu/enabled-state.html +0 -25
- package/demo/elements/context-menu/enabled-state.ts +0 -73
- package/demo/elements/context-menu/icons.html +0 -25
- package/demo/elements/context-menu/icons.ts +0 -64
- package/demo/elements/context-menu/index.html +0 -43
- package/demo/elements/context-menu/nested.html +0 -25
- package/demo/elements/context-menu/nestedt.ts +0 -152
- package/demo/elements/context-menu/no-execute.html +0 -25
- package/demo/elements/context-menu/no-execute.ts +0 -134
- package/demo/elements/context-menu/radio-menu.html +0 -25
- package/demo/elements/context-menu/radio-menu.ts +0 -83
- package/demo/elements/context-menu/separators.html +0 -25
- package/demo/elements/context-menu/separators.ts +0 -172
- package/demo/elements/currency/index.html +0 -91
- package/demo/elements/currency/index.ts +0 -352
- package/demo/elements/environment/environment-editor.html +0 -20
- package/demo/elements/environment/environment-editor.ts +0 -49
- package/demo/elements/environment/index.html +0 -33
- package/demo/elements/environment/server-editor.html +0 -20
- package/demo/elements/environment/server-editor.ts +0 -67
- package/demo/elements/environment/variables-editor.html +0 -20
- package/demo/elements/environment/variables-editor.ts +0 -94
- package/demo/elements/har/har-viewer.html +0 -20
- package/demo/elements/har/har-viewer.ts +0 -76
- package/demo/elements/har/har1.har +0 -3044
- package/demo/elements/har/har2.json +0 -439
- package/demo/elements/har/index.html +0 -26
- package/demo/elements/highlight/example.md +0 -27
- package/demo/elements/highlight/index.html +0 -31
- package/demo/elements/highlight/marked-highlight.html +0 -132
- package/demo/elements/highlight/marked-highlight.ts +0 -22
- package/demo/elements/highlight/prism-highlight.html +0 -62
- package/demo/elements/highlight/prism-highlight.ts +0 -17
- package/demo/elements/http/body-editor.html +0 -17
- package/demo/elements/http/body-editor.ts +0 -115
- package/demo/elements/http/headers.html +0 -17
- package/demo/elements/http/headers.ts +0 -59
- package/demo/elements/http/http-assertions.html +0 -20
- package/demo/elements/http/http-assertions.ts +0 -89
- package/demo/elements/http/http-flows.html +0 -23
- package/demo/elements/http/http-flows.ts +0 -89
- package/demo/elements/http/index.html +0 -45
- package/demo/elements/http/request-editor.html +0 -26
- package/demo/elements/http/request-editor.ts +0 -197
- package/demo/elements/http/request-log.html +0 -16
- package/demo/elements/http/request-log.ts +0 -136
- package/demo/elements/http/url-editing.html +0 -17
- package/demo/elements/http/url-editing.ts +0 -112
- package/demo/elements/icons/index.html +0 -81
- package/demo/elements/icons/index.ts +0 -52
- package/demo/elements/index.html +0 -72
- package/demo/elements/mention-textarea/index.html +0 -19
- package/demo/elements/mention-textarea/index.ts +0 -205
- package/demo/elements/navigation/navigation-item.html +0 -49
- package/demo/elements/navigation/navigation-item.ts +0 -131
- package/demo/elements/navigation/navigation.html +0 -20
- package/demo/elements/navigation/navigation.ts +0 -45
- package/demo/elements/project/index.html +0 -29
- package/demo/elements/project/project-run-report.html +0 -20
- package/demo/elements/project/project-run-report.ts +0 -132
- package/demo/elements/project/request-editor.html +0 -23
- package/demo/elements/project/request-editor.ts +0 -232
- package/demo/elements/user/user-avatar.html +0 -17
- package/demo/elements/user/user-avatar.ts +0 -60
- package/demo/env.js +0 -4
- package/demo/index.html +0 -34
- package/demo/layout/index.html +0 -94
- package/demo/layout/index.ts +0 -190
- package/demo/md/DemoStyles.ts +0 -61
- package/demo/md/UiDemoPage.ts +0 -6
- package/demo/md/buttons/button.html +0 -121
- package/demo/md/buttons/button.ts +0 -246
- package/demo/md/buttons/group.html +0 -36
- package/demo/md/buttons/group.ts +0 -171
- package/demo/md/checkbox/index.html +0 -39
- package/demo/md/checkbox/index.ts +0 -220
- package/demo/md/chip/chip.html +0 -70
- package/demo/md/chip/chip.ts +0 -219
- package/demo/md/chip/pawel6c9a.jpg +0 -0
- package/demo/md/collapse/CustomDetail.ts +0 -89
- package/demo/md/collapse/collapse.html +0 -21
- package/demo/md/collapse/collapse.ts +0 -78
- package/demo/md/date-picker/date-picker.ts +0 -336
- package/demo/md/date-picker/index.html +0 -171
- package/demo/md/dialog/confirm-dialog.html +0 -49
- package/demo/md/dialog/confirm-dialog.ts +0 -121
- package/demo/md/dialog/dialog.html +0 -25
- package/demo/md/dialog/dialog.ts +0 -468
- package/demo/md/dropdown-list/index.html +0 -31
- package/demo/md/dropdown-list/index.ts +0 -158
- package/demo/md/icon-button/index.html +0 -122
- package/demo/md/icon-button/index.ts +0 -132
- package/demo/md/index.html +0 -73
- package/demo/md/inputs/input.html +0 -73
- package/demo/md/inputs/input.ts +0 -278
- package/demo/md/inputs/radio.html +0 -39
- package/demo/md/inputs/radio.ts +0 -156
- package/demo/md/inputs/switch.html +0 -45
- package/demo/md/inputs/switch.ts +0 -144
- package/demo/md/list/list.html +0 -65
- package/demo/md/list/list.ts +0 -204
- package/demo/md/listbox/listbox.html +0 -31
- package/demo/md/listbox/listbox.ts +0 -27
- package/demo/md/menu/index.html +0 -19
- package/demo/md/menu/index.ts +0 -514
- package/demo/md/notification/snack.html +0 -21
- package/demo/md/notification/snack.ts +0 -70
- package/demo/md/progress/progress.html +0 -46
- package/demo/md/progress/progress.ts +0 -161
- package/demo/md/segmented-button/index.html +0 -21
- package/demo/md/segmented-button/index.ts +0 -55
- package/demo/md/select/index.html +0 -16
- package/demo/md/select/index.ts +0 -217
- package/demo/md/tabs/tabs.html +0 -40
- package/demo/md/tabs/tabs.ts +0 -214
- package/demo/oauth-popup.html +0 -36
- package/demo/page.css +0 -8
- package/demo/resources/calendar-month.png +0 -0
- package/demo/resources/favorite.png +0 -0
- package/demo/resources/fingerprint.png +0 -0
- package/demo/resources/home-work.png +0 -0
- package/demo/resources/mood.png +0 -0
- package/demo/resources/print.png +0 -0
- package/demo/resources/stars.png +0 -0
- package/demo/resources/theaters.png +0 -0
- package/demo/tsconfig.json +0 -4
- package/eslint.config.js +0 -97
- package/scripts/copy-assets.js +0 -21
- package/scripts/release.js +0 -66
- package/src/demo/DemoPage.ts +0 -169
- package/src/demo/DemoStyles.ts +0 -60
- package/test/README.md +0 -375
- package/test/contextual-menu/ContextMenu.test.ts +0 -760
- package/test/contextual-menu/ContextMenuElement.test.ts +0 -569
- package/test/core/activity.spec.ts +0 -413
- package/test/core/activity_manager.spec.ts +0 -544
- package/test/core/application.spec.ts +0 -218
- package/test/core/fragment.spec.ts +0 -565
- package/test/core/fragment_manager.spec.ts +0 -404
- package/test/core/live_data.spec.ts +0 -558
- package/test/core/renderer.spec.ts +0 -113
- package/test/dom-assertions.test.ts +0 -182
- package/test/elements/MonacoSetup.ts +0 -65
- package/test/elements/authorization/basic-method.test.ts +0 -177
- package/test/elements/authorization/bearer-method.test.ts +0 -143
- package/test/elements/authorization/ntlm-method.test.ts +0 -219
- package/test/elements/authorization/oauth2-client-credentials-method.test.ts +0 -334
- package/test/elements/authorization/oauth2-code-method.test.ts +0 -320
- package/test/elements/authorization/oauth2-custom-grant-method.test.ts +0 -255
- package/test/elements/authorization/oauth2-device-code-method.test.ts +0 -371
- package/test/elements/authorization/oauth2-implicit-method.test.ts +0 -407
- package/test/elements/authorization/oauth2-jwt-method.test.ts +0 -217
- package/test/elements/authorization/oauth2-password-method.test.ts +0 -275
- package/test/elements/authorization/openid-method.test.ts +0 -591
- package/test/elements/autocomplete/autocomplete-input.spec.ts +0 -646
- package/test/elements/code-editor/code-editor.accessibility.test.ts +0 -298
- package/test/elements/code-editor/code-editor.test.ts +0 -574
- package/test/elements/currency/CurrencyPicker.accessibility.test.ts +0 -328
- package/test/elements/currency/CurrencyPicker.core.test.ts +0 -318
- package/test/elements/currency/CurrencyPicker.integration.test.ts +0 -482
- package/test/elements/currency/CurrencyPicker.test.ts +0 -486
- package/test/elements/data-table/DataTable.browser.test.ts +0 -649
- package/test/elements/har/HarUtils.test.ts +0 -45
- package/test/elements/har/HarViewerElement.test.ts +0 -687
- package/test/elements/har/test-data/har1.har +0 -3044
- package/test/elements/highlight/MarkedHighlightElement.test.ts +0 -452
- package/test/elements/highlight/PrismHighlightElement.test.ts +0 -79
- package/test/elements/highlight/PrismHighlighter.test.ts +0 -94
- package/test/elements/highlight/remoteSanitization.md +0 -1
- package/test/elements/highlight/test.md +0 -3
- package/test/elements/highlight/test1.md +0 -3
- package/test/elements/highlight/test2.md +0 -1
- package/test/elements/http/BodyFormdataEditorElement.test.ts +0 -482
- package/test/elements/http/BodyMultipartEditorElement.test.ts +0 -658
- package/test/elements/http/BodyRawEditorElement.test.ts +0 -90
- package/test/elements/http/CertificateAdd.test.ts +0 -457
- package/test/elements/http/HttpAssertions.test.ts +0 -994
- package/test/elements/http/HttpFlows.test.ts +0 -502
- package/test/elements/http/UrlEncodeUtils.test.ts +0 -202
- package/test/elements/layout/SplitItem.test.ts +0 -440
- package/test/elements/layout/SplitLayoutManager.test.ts +0 -1501
- package/test/elements/layout/SplitPanel.test.ts +0 -1109
- package/test/elements/mention-textarea/MentionTextArea.basic.test.ts +0 -114
- package/test/elements/mention-textarea/MentionTextArea.test.ts +0 -613
- package/test/elements/navigation/Navigation.test.ts +0 -120
- package/test/env.ts +0 -15
- package/test/events/EventTypes.test.ts +0 -363
- package/test/events/EventsTestHelpers.ts +0 -16
- package/test/helpers/TestUtils.ts +0 -243
- package/test/helpers/UiMock.ts +0 -185
- package/test/lib/Dom.test.ts +0 -231
- package/test/md/button/UiButton.test.ts +0 -347
- package/test/md/button/UiIconButton.test.ts +0 -155
- package/test/md/chip/UiChip.test.ts +0 -219
- package/test/md/collapse/UiCollapse.test.ts +0 -250
- package/test/md/collapse/flex-layout.test.ts +0 -105
- package/test/md/date-time/DateTime.test.ts +0 -348
- package/test/md/dialog/UiConfirmDialog.test.ts +0 -131
- package/test/md/dialog/UiDialog.test.ts +0 -759
- package/test/md/menu/Menu.test.ts +0 -855
- package/test/md/menu/MenuIntegration.test.ts +0 -426
- package/test/md/menu/MenuItem.test.ts +0 -652
- package/test/md/menu/SubMenu.test.ts +0 -410
- package/test/md/progress/UiCircularProgressElement.test.ts +0 -481
- package/test/md/progress/UiProgressElement.test.ts +0 -117
- package/test/md/progress/UiRangeElement.test.ts +0 -156
- package/test/md/select/Select.test.ts +0 -925
- package/test/plugins/takeScreenshotPlugin.js +0 -35
- package/test/setup.test.ts +0 -217
- package/test/setup.ts +0 -117
- package/test/tsconfig.json +0 -7
- package/web-dev-server.config.js +0 -21
- package/web-test-runner.config.js +0 -90
|
@@ -1,347 +0,0 @@
|
|
|
1
|
-
import { assert, fixture, html, nextFrame } from '@open-wc/testing'
|
|
2
|
-
import UiButton from '../../../src/md/button/internals/button.js'
|
|
3
|
-
import { UiMock } from '../../helpers/UiMock.js'
|
|
4
|
-
|
|
5
|
-
import '../../../src/md/button/ui-button.js'
|
|
6
|
-
import '../../../src/md/icons/ui-icon.js'
|
|
7
|
-
|
|
8
|
-
describe('md', () => {
|
|
9
|
-
describe('UiButton', () => {
|
|
10
|
-
async function basicFixture(): Promise<UiButton> {
|
|
11
|
-
return fixture(html`<ui-button color="filled">Label</ui-button>`)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async function formFixture(): Promise<HTMLFormElement> {
|
|
15
|
-
return fixture(
|
|
16
|
-
html`<form>
|
|
17
|
-
<input name="text" value="abc" />
|
|
18
|
-
<ui-button color="filled">Label</ui-button>
|
|
19
|
-
</form>`
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function submitFormFixture(): Promise<HTMLFormElement> {
|
|
24
|
-
return fixture(
|
|
25
|
-
html`<form>
|
|
26
|
-
<input name="text" value="abc" />
|
|
27
|
-
<ui-button color="filled" name="button" value="ok" type="submit">Label</ui-button>
|
|
28
|
-
</form>`
|
|
29
|
-
)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async function disabledFormFixture(): Promise<HTMLFormElement> {
|
|
33
|
-
return fixture(
|
|
34
|
-
html`<form>
|
|
35
|
-
<input name="text" value="abc" />
|
|
36
|
-
<ui-button color="filled" name="button" value="ok" type="submit" disabled>Label</ui-button>
|
|
37
|
-
</form>`
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async function disabledFixture(): Promise<UiButton> {
|
|
42
|
-
return fixture(html`<ui-button color="filled" disabled>Label</ui-button>`)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async function tabindexFixture(): Promise<UiButton> {
|
|
46
|
-
return fixture(html`<ui-button color="filled" tabindex="1">Label</ui-button>`)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async function iconFixture(): Promise<UiButton> {
|
|
50
|
-
return fixture(
|
|
51
|
-
html`<ui-button color="filled">
|
|
52
|
-
<ui-icon slot="icon" icon="add"></ui-icon>
|
|
53
|
-
Label
|
|
54
|
-
</ui-button>`
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
async function trailingIconFixture(): Promise<UiButton> {
|
|
59
|
-
return fixture(
|
|
60
|
-
html`<ui-button color="filled" trailingIcon>
|
|
61
|
-
<ui-icon slot="icon" icon="add"></ui-icon>
|
|
62
|
-
Label
|
|
63
|
-
</ui-button>`
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
async function toggleFixture(): Promise<UiButton> {
|
|
68
|
-
return fixture(
|
|
69
|
-
html`<ui-button color="filled" toggle>
|
|
70
|
-
<ui-icon slot="icon" icon="add"></ui-icon>
|
|
71
|
-
Label
|
|
72
|
-
</ui-button>`
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async function toggleSelectedFixture(): Promise<UiButton> {
|
|
77
|
-
return fixture(
|
|
78
|
-
html`<ui-button color="filled" toggle selected>
|
|
79
|
-
<ui-icon slot="icon" icon="add"></ui-icon>
|
|
80
|
-
Label
|
|
81
|
-
</ui-button>`
|
|
82
|
-
)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
describe('Form button', () => {
|
|
86
|
-
it('has formAssociated set', async () => {
|
|
87
|
-
assert.isTrue(UiButton.formAssociated)
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
it('has no form when not in form', async () => {
|
|
91
|
-
const button = await basicFixture()
|
|
92
|
-
assert.isNull(button.form)
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
it('has form when in a form', async () => {
|
|
96
|
-
const form = await formFixture()
|
|
97
|
-
const button = form.querySelector('ui-button')!
|
|
98
|
-
assert.ok(button.form, 'has a form')
|
|
99
|
-
assert.isTrue(button.form === form, 'has the parent form')
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
it('does not trigger submit when not "submit"', async () => {
|
|
103
|
-
const form = await formFixture()
|
|
104
|
-
const button = form.querySelector('ui-button')!
|
|
105
|
-
let event: Event | undefined
|
|
106
|
-
form.addEventListener('submit', (e: SubmitEvent) => {
|
|
107
|
-
e.preventDefault()
|
|
108
|
-
event = e
|
|
109
|
-
})
|
|
110
|
-
button.click()
|
|
111
|
-
assert.notOk(event)
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
it('removes the native "button" after submitting', async () => {
|
|
115
|
-
const form = await submitFormFixture()
|
|
116
|
-
const button = form.querySelector('ui-button')!
|
|
117
|
-
form.addEventListener('submit', (e: SubmitEvent) => {
|
|
118
|
-
e.preventDefault()
|
|
119
|
-
})
|
|
120
|
-
button.click()
|
|
121
|
-
const nativeButton = form.querySelector('button')
|
|
122
|
-
assert.notOk(nativeButton)
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
it('registers the form values', async () => {
|
|
126
|
-
const form = await submitFormFixture()
|
|
127
|
-
const button = form.querySelector('ui-button')!
|
|
128
|
-
assert.isTrue(form.elements[1] === button, 'the form has the button')
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
it('submits the form when clicking on the button', async () => {
|
|
132
|
-
const form = await submitFormFixture()
|
|
133
|
-
const button = form.querySelector('ui-button')!
|
|
134
|
-
let event: SubmitEvent | undefined
|
|
135
|
-
form.addEventListener('submit', (e: SubmitEvent) => {
|
|
136
|
-
e.preventDefault()
|
|
137
|
-
event = e
|
|
138
|
-
})
|
|
139
|
-
button.click()
|
|
140
|
-
assert.ok(event, 'has the event')
|
|
141
|
-
const submitter = event!.submitter as UiButton
|
|
142
|
-
assert.equal(submitter.value, 'ok', 'submitter has the value')
|
|
143
|
-
assert.equal(submitter.name, 'button', 'submitter has the name')
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
it('submits the form with Space bar', async () => {
|
|
147
|
-
const form = await submitFormFixture()
|
|
148
|
-
const button = form.querySelector('ui-button')!
|
|
149
|
-
let event: SubmitEvent | undefined
|
|
150
|
-
form.addEventListener('submit', (e: SubmitEvent) => {
|
|
151
|
-
e.preventDefault()
|
|
152
|
-
event = e
|
|
153
|
-
})
|
|
154
|
-
await UiMock.keyPress(button, 'Space')
|
|
155
|
-
assert.ok(event)
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
it('submits the form with Enter', async () => {
|
|
159
|
-
const form = await submitFormFixture()
|
|
160
|
-
const button = form.querySelector('ui-button')!
|
|
161
|
-
let event: SubmitEvent | undefined
|
|
162
|
-
form.addEventListener('submit', (e: SubmitEvent) => {
|
|
163
|
-
e.preventDefault()
|
|
164
|
-
event = e
|
|
165
|
-
})
|
|
166
|
-
await UiMock.keyPress(button, 'Enter')
|
|
167
|
-
assert.ok(event)
|
|
168
|
-
})
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
describe('Disabled button', () => {
|
|
172
|
-
it('is not disabled by default', async () => {
|
|
173
|
-
const button = await basicFixture()
|
|
174
|
-
assert.isFalse(button.disabled)
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
it('has no aria-disabled by default', async () => {
|
|
178
|
-
const button = await basicFixture()
|
|
179
|
-
assert.isFalse(button.hasAttribute('aria-disabled'))
|
|
180
|
-
})
|
|
181
|
-
|
|
182
|
-
it('is is disabled via the markup', async () => {
|
|
183
|
-
const button = await disabledFixture()
|
|
184
|
-
assert.isTrue(button.disabled)
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
it('removes the tabindex', async () => {
|
|
188
|
-
const button = await disabledFixture()
|
|
189
|
-
assert.isFalse(button.hasAttribute('tabindex'))
|
|
190
|
-
})
|
|
191
|
-
|
|
192
|
-
it('sets the aria-disabled attribute', async () => {
|
|
193
|
-
const button = await disabledFixture()
|
|
194
|
-
assert.equal(button.getAttribute('aria-disabled'), 'true')
|
|
195
|
-
})
|
|
196
|
-
|
|
197
|
-
it('disables the button via property setter', async () => {
|
|
198
|
-
const button = await basicFixture()
|
|
199
|
-
button.disabled = true
|
|
200
|
-
assert.equal(button.getAttribute('aria-disabled'), 'true')
|
|
201
|
-
assert.isFalse(button.hasAttribute('tabindex'))
|
|
202
|
-
})
|
|
203
|
-
|
|
204
|
-
it('restores the button from the disabled state', async () => {
|
|
205
|
-
const button = await tabindexFixture()
|
|
206
|
-
button.disabled = true
|
|
207
|
-
await nextFrame()
|
|
208
|
-
button.disabled = false
|
|
209
|
-
await nextFrame()
|
|
210
|
-
assert.equal(button.getAttribute('tabindex'), '1')
|
|
211
|
-
assert.isFalse(button.hasAttribute('aria-disabled'))
|
|
212
|
-
})
|
|
213
|
-
|
|
214
|
-
it('does not trigger submit when disabled', async () => {
|
|
215
|
-
const form = await disabledFormFixture()
|
|
216
|
-
const button = form.querySelector('ui-button')!
|
|
217
|
-
let event: Event | undefined
|
|
218
|
-
form.addEventListener('submit', (e: SubmitEvent) => {
|
|
219
|
-
e.preventDefault()
|
|
220
|
-
event = e
|
|
221
|
-
})
|
|
222
|
-
button.click()
|
|
223
|
-
assert.notOk(event)
|
|
224
|
-
})
|
|
225
|
-
})
|
|
226
|
-
|
|
227
|
-
describe('Icon placement', () => {
|
|
228
|
-
it('places the icon as a prefix by default', async () => {
|
|
229
|
-
const button = await iconFixture()
|
|
230
|
-
const content = button.shadowRoot!
|
|
231
|
-
assert.equal(content?.children[2].localName, 'slot')
|
|
232
|
-
})
|
|
233
|
-
|
|
234
|
-
it('places the icon as a suffix', async () => {
|
|
235
|
-
const button = await trailingIconFixture()
|
|
236
|
-
const content = button.shadowRoot!
|
|
237
|
-
assert.equal(content?.children[3].localName, 'slot')
|
|
238
|
-
})
|
|
239
|
-
})
|
|
240
|
-
|
|
241
|
-
describe('Ripple effect', () => {
|
|
242
|
-
it('renders the ripple element', async () => {
|
|
243
|
-
const button = await basicFixture()
|
|
244
|
-
const ripple = button.shadowRoot!.querySelector('ui-ripple')
|
|
245
|
-
assert.ok(ripple)
|
|
246
|
-
})
|
|
247
|
-
})
|
|
248
|
-
|
|
249
|
-
describe('a11y', () => {
|
|
250
|
-
it('is accessible when in a default state', async () => {
|
|
251
|
-
const button = await basicFixture()
|
|
252
|
-
await assert.isAccessible(button)
|
|
253
|
-
})
|
|
254
|
-
|
|
255
|
-
it('is accessible when in the disabled state', async () => {
|
|
256
|
-
const button = await disabledFixture()
|
|
257
|
-
await assert.isAccessible(button)
|
|
258
|
-
})
|
|
259
|
-
|
|
260
|
-
it('sets the role', async () => {
|
|
261
|
-
const button = await basicFixture()
|
|
262
|
-
assert.equal(button.getAttribute('role'), 'button')
|
|
263
|
-
})
|
|
264
|
-
|
|
265
|
-
it('sets the tabindex', async () => {
|
|
266
|
-
const button = await basicFixture()
|
|
267
|
-
assert.equal(button.getAttribute('tabindex'), '0')
|
|
268
|
-
})
|
|
269
|
-
|
|
270
|
-
it('respects the existing tabindex', async () => {
|
|
271
|
-
const button = await tabindexFixture()
|
|
272
|
-
assert.equal(button.getAttribute('tabindex'), '1')
|
|
273
|
-
})
|
|
274
|
-
|
|
275
|
-
it('is accessible when not selected', async () => {
|
|
276
|
-
const button = await toggleFixture()
|
|
277
|
-
await assert.isAccessible(button)
|
|
278
|
-
})
|
|
279
|
-
|
|
280
|
-
it('is accessible when selected', async () => {
|
|
281
|
-
const button = await toggleSelectedFixture()
|
|
282
|
-
await assert.isAccessible(button)
|
|
283
|
-
})
|
|
284
|
-
})
|
|
285
|
-
|
|
286
|
-
describe('Value and Name', () => {
|
|
287
|
-
it('sets the value', async () => {
|
|
288
|
-
const button = await basicFixture()
|
|
289
|
-
button.value = 'test'
|
|
290
|
-
assert.equal(button.value, 'test')
|
|
291
|
-
})
|
|
292
|
-
|
|
293
|
-
it('sets the name', async () => {
|
|
294
|
-
const button = await basicFixture()
|
|
295
|
-
button.name = 'test'
|
|
296
|
-
assert.equal(button.name, 'test')
|
|
297
|
-
})
|
|
298
|
-
|
|
299
|
-
it('sets the form value', async () => {
|
|
300
|
-
const button = await basicFixture()
|
|
301
|
-
button.value = 'test'
|
|
302
|
-
await nextFrame()
|
|
303
|
-
assert.equal(button.value, 'test')
|
|
304
|
-
})
|
|
305
|
-
})
|
|
306
|
-
|
|
307
|
-
describe('Type', () => {
|
|
308
|
-
it('sets the default type', async () => {
|
|
309
|
-
const button = await basicFixture()
|
|
310
|
-
assert.equal(button.type, 'button')
|
|
311
|
-
})
|
|
312
|
-
|
|
313
|
-
it('sets the type', async () => {
|
|
314
|
-
const button = await basicFixture()
|
|
315
|
-
button.type = 'submit'
|
|
316
|
-
assert.equal(button.type, 'submit')
|
|
317
|
-
})
|
|
318
|
-
})
|
|
319
|
-
|
|
320
|
-
describe('Internals', () => {
|
|
321
|
-
it('has validity', async () => {
|
|
322
|
-
const button = await basicFixture()
|
|
323
|
-
assert.ok(button.validity)
|
|
324
|
-
})
|
|
325
|
-
|
|
326
|
-
it('has empty validationMessage', async () => {
|
|
327
|
-
const button = await basicFixture()
|
|
328
|
-
assert.equal(button.validationMessage, '')
|
|
329
|
-
})
|
|
330
|
-
|
|
331
|
-
it('has willValidate', async () => {
|
|
332
|
-
const button = await basicFixture()
|
|
333
|
-
assert.ok(button.willValidate)
|
|
334
|
-
})
|
|
335
|
-
|
|
336
|
-
it('calls checkValidity', async () => {
|
|
337
|
-
const button = await basicFixture()
|
|
338
|
-
assert.isTrue(button.checkValidity())
|
|
339
|
-
})
|
|
340
|
-
|
|
341
|
-
it('calls reportValidity', async () => {
|
|
342
|
-
const button = await basicFixture()
|
|
343
|
-
assert.isTrue(button.reportValidity())
|
|
344
|
-
})
|
|
345
|
-
})
|
|
346
|
-
})
|
|
347
|
-
})
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { assert, fixture, html, nextFrame, oneEvent } from '@open-wc/testing'
|
|
2
|
-
import sinon from 'sinon'
|
|
3
|
-
import UiIconButton from '../../../src/md/icon-button/internals/IconButton.js'
|
|
4
|
-
import { UiMock } from '../../helpers/UiMock.js'
|
|
5
|
-
import { IconType } from '../../../src/md/icons/Icons.js'
|
|
6
|
-
|
|
7
|
-
import '../../../src/md/icon-button/ui-icon-button.js'
|
|
8
|
-
import '../../../src/md/icons/ui-icon.js'
|
|
9
|
-
|
|
10
|
-
describe('md', () => {
|
|
11
|
-
describe('UiIconButton', () => {
|
|
12
|
-
async function basicFixture(icon: IconType): Promise<UiIconButton> {
|
|
13
|
-
return fixture(html`<ui-icon-button><ui-icon .icon="${icon}"></ui-icon></ui-icon-button>`)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async function toggleFixture(icon: IconType): Promise<UiIconButton> {
|
|
17
|
-
return fixture(html`<ui-icon-button toggle><ui-icon .icon="${icon}"></ui-icon></ui-icon-button>`)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async function tabindexFixture(icon: IconType): Promise<UiIconButton> {
|
|
21
|
-
return fixture(html`<ui-icon-button tabindex="-1"><ui-icon .icon="${icon}"></ui-icon></ui-icon-button>`)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async function labeledFixture(icon: IconType): Promise<UiIconButton> {
|
|
25
|
-
return fixture(
|
|
26
|
-
html`<ui-icon-button aria-label="My button" title="My button description"
|
|
27
|
-
><ui-icon .icon="${icon}"></ui-icon
|
|
28
|
-
></ui-icon-button>`
|
|
29
|
-
)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async function labeledToggleFixture(icon: IconType): Promise<UiIconButton> {
|
|
33
|
-
return fixture(
|
|
34
|
-
html`<ui-icon-button aria-label="My button" title="My button description" toggle
|
|
35
|
-
><ui-icon .icon="${icon}"></ui-icon
|
|
36
|
-
></ui-icon-button>`
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function labeledSelectedToggleFixture(icon: IconType): Promise<UiIconButton> {
|
|
41
|
-
return fixture(
|
|
42
|
-
html`<ui-icon-button aria-label="My button" title="My button description" toggle selected
|
|
43
|
-
><ui-icon .icon="${icon}"></ui-icon
|
|
44
|
-
></ui-icon-button>`
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
describe('toggle button', () => {
|
|
49
|
-
it('sets button selected when pressing the button with space', async () => {
|
|
50
|
-
const button = await toggleFixture('add')
|
|
51
|
-
await UiMock.keyPress(button, 'Space')
|
|
52
|
-
await nextFrame()
|
|
53
|
-
assert.isTrue(button.selected, 'button is selected')
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
it('sets button selected when pressing the button with enter', async () => {
|
|
57
|
-
const button = await toggleFixture('add')
|
|
58
|
-
await UiMock.keyPress(button, 'Enter')
|
|
59
|
-
await nextFrame()
|
|
60
|
-
assert.isTrue(button.selected, 'button is selected')
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
it('sets button selected when clicking on the button', async () => {
|
|
64
|
-
const button = await toggleFixture('add')
|
|
65
|
-
button.click()
|
|
66
|
-
await nextFrame()
|
|
67
|
-
assert.isTrue(button.selected, 'button is selected')
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it('sets "aria-pressed" when toggling the button', async () => {
|
|
71
|
-
const button = await toggleFixture('add')
|
|
72
|
-
await UiMock.keyPress(button, 'Space')
|
|
73
|
-
await nextFrame()
|
|
74
|
-
assert.equal(button.getAttribute('aria-pressed'), 'true')
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
it('dispatches the "toggle" event when toggling', async () => {
|
|
78
|
-
const button = await toggleFixture('add')
|
|
79
|
-
UiMock.keyPress(button, 'Space')
|
|
80
|
-
const e = await oneEvent(button, 'toggle')
|
|
81
|
-
assert.ok(e, 'dispatches the event')
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
it('does not dispatch the "toggle" event toggling attribute', async () => {
|
|
85
|
-
const button = await toggleFixture('add')
|
|
86
|
-
const spy = sinon.spy()
|
|
87
|
-
button.addEventListener('toggle', spy)
|
|
88
|
-
button.selected = true
|
|
89
|
-
await nextFrame()
|
|
90
|
-
assert.isFalse(spy.called)
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
it('dispatches the "click" event when toggling', async () => {
|
|
94
|
-
const button = await toggleFixture('add')
|
|
95
|
-
const spy = sinon.spy()
|
|
96
|
-
button.addEventListener('click', spy)
|
|
97
|
-
await UiMock.keyPress(button, 'Space')
|
|
98
|
-
await nextFrame()
|
|
99
|
-
assert.isTrue(spy.called)
|
|
100
|
-
})
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
describe('non-toggle button', () => {
|
|
104
|
-
it('clicks when pressing the button with space', async () => {
|
|
105
|
-
const button = await basicFixture('add')
|
|
106
|
-
const spy = sinon.spy()
|
|
107
|
-
button.addEventListener('click', spy)
|
|
108
|
-
await UiMock.keyPress(button, 'Space')
|
|
109
|
-
await nextFrame()
|
|
110
|
-
assert.isTrue(spy.calledOnce, 'event dispatched only once')
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
it('clicks when pressing the button with enter', async () => {
|
|
114
|
-
const button = await basicFixture('add')
|
|
115
|
-
const spy = sinon.spy()
|
|
116
|
-
button.addEventListener('click', spy)
|
|
117
|
-
await UiMock.keyPress(button, 'Enter')
|
|
118
|
-
await nextFrame()
|
|
119
|
-
assert.isTrue(spy.calledOnce, 'event dispatched only once')
|
|
120
|
-
})
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
describe('a11y', () => {
|
|
124
|
-
it('has the role', async () => {
|
|
125
|
-
const button = await basicFixture('add')
|
|
126
|
-
assert.equal(button.getAttribute('role'), 'button')
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
it('has the tabindex', async () => {
|
|
130
|
-
const button = await basicFixture('add')
|
|
131
|
-
assert.equal(button.getAttribute('tabindex'), '0')
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
it('respects the existing tabindex', async () => {
|
|
135
|
-
const button = await tabindexFixture('add')
|
|
136
|
-
assert.equal(button.getAttribute('tabindex'), '-1')
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
it('is accessible for regular button', async () => {
|
|
140
|
-
const button = await labeledFixture('add')
|
|
141
|
-
await assert.isAccessible(button)
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
it('is accessible when not selected', async () => {
|
|
145
|
-
const button = await labeledToggleFixture('add')
|
|
146
|
-
await assert.isAccessible(button)
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
it('is accessible when selected', async () => {
|
|
150
|
-
const button = await labeledSelectedToggleFixture('add')
|
|
151
|
-
await assert.isAccessible(button)
|
|
152
|
-
})
|
|
153
|
-
})
|
|
154
|
-
})
|
|
155
|
-
})
|