@api-client/ui 0.5.38 → 0.5.40
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/md/list/internals/ListItem.d.ts +24 -15
- package/build/src/md/list/internals/ListItem.d.ts.map +1 -1
- package/build/src/md/list/internals/ListItem.js +85 -59
- package/build/src/md/list/internals/ListItem.js.map +1 -1
- package/build/src/md/list/internals/ListItem.styles.js +11 -11
- package/build/src/md/list/internals/ListItem.styles.js.map +1 -1
- package/build/src/md/select/internals/Option.d.ts +4 -14
- package/build/src/md/select/internals/Option.d.ts.map +1 -1
- package/build/src/md/select/internals/Option.js +13 -28
- package/build/src/md/select/internals/Option.js.map +1 -1
- package/build/src/md/select/internals/Select.d.ts +1 -1
- package/build/src/md/select/internals/Select.d.ts.map +1 -1
- package/build/src/md/select/internals/Select.js +15 -5
- package/build/src/md/select/internals/Select.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
- package/src/md/list/internals/ListItem.styles.ts +11 -11
- package/src/md/list/internals/ListItem.ts +68 -43
- package/src/md/select/internals/Option.ts +14 -26
- package/src/md/select/internals/Select.ts +15 -5
- 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/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 -207
- 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,219 +0,0 @@
|
|
|
1
|
-
import { assert, fixture, html, nextFrame } from '@open-wc/testing'
|
|
2
|
-
import sinon from 'sinon'
|
|
3
|
-
import UiChip from '../../../src/md/chip/internals/Chip.js'
|
|
4
|
-
import { UiMock } from '../../helpers/UiMock.js'
|
|
5
|
-
import { ColorConverter } from '@api-client/core/browser.js'
|
|
6
|
-
import '../../../src/md/chip/ui-chip.js'
|
|
7
|
-
import '../../../src/md/icons/ui-icon.js'
|
|
8
|
-
|
|
9
|
-
describe('md', () => {
|
|
10
|
-
describe('UiButton', () => {
|
|
11
|
-
describe('Assist chip', () => {
|
|
12
|
-
async function basicFixture(): Promise<UiChip> {
|
|
13
|
-
return fixture(html`<ui-chip type="assist">Enabled</ui-chip>`)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async function disabledFixture(): Promise<UiChip> {
|
|
17
|
-
return fixture(html`<ui-chip type="assist" disabled>Disabled</ui-chip>`)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async function iconFixture(): Promise<UiChip> {
|
|
21
|
-
return fixture(
|
|
22
|
-
html`<ui-chip type="assist">
|
|
23
|
-
<ui-icon slot="icon" icon="add"></ui-icon>
|
|
24
|
-
With icon
|
|
25
|
-
</ui-chip>`
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async function elevatedFixture(): Promise<UiChip> {
|
|
30
|
-
return fixture(html`<ui-chip type="assist" elevated>Elevated</ui-chip>`)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async function disabledElevatedFixture(): Promise<UiChip> {
|
|
34
|
-
return fixture(html`<ui-chip type="assist" elevated disabled>Elevated</ui-chip>`)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
it('renders border around a regular assist chip', async () => {
|
|
38
|
-
const element = await basicFixture()
|
|
39
|
-
const styles = getComputedStyle(element)
|
|
40
|
-
const m3Color = styles.getPropertyValue('--md-sys-color-outline-variant')
|
|
41
|
-
const borderColor = ColorConverter.normalizeColor(styles.borderColor)
|
|
42
|
-
const compareColor = ColorConverter.normalizeColor(m3Color)
|
|
43
|
-
assert.equal(borderColor, compareColor, 'has the m3 color')
|
|
44
|
-
assert.equal(styles.borderWidth, '1px', 'has the width')
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it('dispatches the click event on space press', async () => {
|
|
48
|
-
const element = await basicFixture()
|
|
49
|
-
const spy = sinon.spy()
|
|
50
|
-
element.addEventListener('click', spy)
|
|
51
|
-
await UiMock.keyPress(element, 'Space')
|
|
52
|
-
assert.isTrue(spy.calledOnce)
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
it('dispatches the click event on space enter', async () => {
|
|
56
|
-
const element = await basicFixture()
|
|
57
|
-
const spy = sinon.spy()
|
|
58
|
-
element.addEventListener('click', spy)
|
|
59
|
-
await UiMock.keyPress(element, 'Enter')
|
|
60
|
-
assert.isTrue(spy.calledOnce)
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
it('does not dispatch the click event on disabled chip', async () => {
|
|
64
|
-
const element = await disabledFixture()
|
|
65
|
-
const spy = sinon.spy()
|
|
66
|
-
element.addEventListener('click', spy)
|
|
67
|
-
await UiMock.keyPress(element, 'Space')
|
|
68
|
-
await UiMock.keyPress(element, 'Enter')
|
|
69
|
-
assert.isFalse(spy.called)
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
it('does not dispatch the select event', async () => {
|
|
73
|
-
const element = await disabledFixture()
|
|
74
|
-
const spy = sinon.spy()
|
|
75
|
-
element.addEventListener('event', spy)
|
|
76
|
-
await UiMock.keyPress(element, 'Space')
|
|
77
|
-
assert.isFalse(spy.called)
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
it('renders suffix icon', async () => {
|
|
81
|
-
const element = await iconFixture()
|
|
82
|
-
const surface = element.shadowRoot!.querySelector<HTMLDivElement>('.surface')!
|
|
83
|
-
assert.isTrue(surface.classList.contains('has-icon'), 'the surface has the has-icon class')
|
|
84
|
-
const contentStyles = getComputedStyle(surface)
|
|
85
|
-
assert.equal(contentStyles.paddingLeft.trim(), '8px', 'the container has the padding')
|
|
86
|
-
const icon = element.querySelector('ui-icon')!
|
|
87
|
-
const iconStyles = getComputedStyle(icon)
|
|
88
|
-
assert.equal(iconStyles.marginRight.trim(), '8px', 'the icon has the margin')
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
it('has elevated styles', async () => {
|
|
92
|
-
const element = await elevatedFixture()
|
|
93
|
-
const surface = element.shadowRoot!.querySelector<HTMLDivElement>('.surface')!
|
|
94
|
-
const containerStyles = getComputedStyle(surface)
|
|
95
|
-
assert.equal(containerStyles.borderWidth, '0px', 'has no border')
|
|
96
|
-
assert.isNotEmpty(containerStyles.boxShadow, 'has a box shadow')
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
it('has no elevated styles when disabled', async () => {
|
|
100
|
-
const element = await disabledElevatedFixture()
|
|
101
|
-
const surface = element.shadowRoot!.querySelector<HTMLDivElement>('.surface')!
|
|
102
|
-
const containerStyles = getComputedStyle(surface)
|
|
103
|
-
assert.equal(containerStyles.boxShadow, 'none', 'has no box shadow')
|
|
104
|
-
})
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
describe('Filter chip', () => {
|
|
108
|
-
async function basicFixture(): Promise<UiChip> {
|
|
109
|
-
return fixture(html`<ui-chip type="filter">Enabled</ui-chip>`)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
async function disabledFixture(): Promise<UiChip> {
|
|
113
|
-
return fixture(html`<ui-chip type="filter" disabled>Disabled</ui-chip>`)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async function removableFixture(): Promise<UiChip> {
|
|
117
|
-
return fixture(html`<ui-chip type="filter" removable>removable</ui-chip>`)
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
async function listFixture(): Promise<UiChip> {
|
|
121
|
-
return fixture(html`<ui-chip type="filter" list>List</ui-chip>`)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
it('renders border around the chip', async () => {
|
|
125
|
-
const element = await basicFixture()
|
|
126
|
-
const styles = getComputedStyle(element)
|
|
127
|
-
const m3Color = styles.getPropertyValue('--md-sys-color-outline-variant')
|
|
128
|
-
const borderColor = ColorConverter.normalizeColor(styles.borderColor)
|
|
129
|
-
const compareColor = ColorConverter.normalizeColor(m3Color)
|
|
130
|
-
assert.equal(borderColor, compareColor, 'has the m3 color')
|
|
131
|
-
assert.equal(styles.borderWidth, '1px', 'has the width')
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
it('dispatches the click event on space press', async () => {
|
|
135
|
-
const element = await basicFixture()
|
|
136
|
-
const spy = sinon.spy()
|
|
137
|
-
element.addEventListener('click', spy)
|
|
138
|
-
await UiMock.keyPress(element, 'Space')
|
|
139
|
-
assert.isTrue(spy.calledOnce)
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
it('dispatches the click event on enter', async () => {
|
|
143
|
-
const element = await basicFixture()
|
|
144
|
-
const spy = sinon.spy()
|
|
145
|
-
element.addEventListener('click', spy)
|
|
146
|
-
await UiMock.keyPress(element, 'Enter')
|
|
147
|
-
assert.isTrue(spy.calledOnce)
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
it('toggles the chip', async () => {
|
|
151
|
-
const element = await basicFixture()
|
|
152
|
-
element.click()
|
|
153
|
-
await nextFrame()
|
|
154
|
-
assert.isTrue(element.checked, 'the element is checked')
|
|
155
|
-
const icon = element.shadowRoot!.querySelector('.leading-icon.check-mark')
|
|
156
|
-
assert.ok(icon, 'renders the check mark icon')
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
it('does not dispatch the click event on disabled chip', async () => {
|
|
160
|
-
const element = await disabledFixture()
|
|
161
|
-
const spy = sinon.spy()
|
|
162
|
-
element.addEventListener('click', spy)
|
|
163
|
-
await UiMock.keyPress(element, 'Space')
|
|
164
|
-
await UiMock.keyPress(element, 'Enter')
|
|
165
|
-
assert.isFalse(spy.called)
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
it('dispatches the select event', async () => {
|
|
169
|
-
const element = await basicFixture()
|
|
170
|
-
const spy = sinon.spy()
|
|
171
|
-
element.addEventListener('select', spy)
|
|
172
|
-
await UiMock.keyPress(element, 'Space')
|
|
173
|
-
assert.isTrue(spy.calledOnce)
|
|
174
|
-
})
|
|
175
|
-
|
|
176
|
-
it('does not dispatch the select event when disabled', async () => {
|
|
177
|
-
const element = await disabledFixture()
|
|
178
|
-
const spy = sinon.spy()
|
|
179
|
-
element.addEventListener('select', spy)
|
|
180
|
-
await UiMock.keyPress(element, 'Space')
|
|
181
|
-
assert.isFalse(spy.called)
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
it('does not render the close icon', async () => {
|
|
185
|
-
const element = await removableFixture()
|
|
186
|
-
const node = element.shadowRoot!.querySelector('.trailing-icon')
|
|
187
|
-
assert.notOk(node)
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
it('renders the list icon', async () => {
|
|
191
|
-
const element = await listFixture()
|
|
192
|
-
const node = element.shadowRoot!.querySelector('.trailing-icon')
|
|
193
|
-
assert.ok(node, 'has the icon')
|
|
194
|
-
})
|
|
195
|
-
|
|
196
|
-
it('is accessible in a regular state', async () => {
|
|
197
|
-
const element = await basicFixture()
|
|
198
|
-
await assert.isAccessible(element)
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
it('is accessible when removable', async () => {
|
|
202
|
-
const element = await removableFixture()
|
|
203
|
-
await assert.isAccessible(element)
|
|
204
|
-
})
|
|
205
|
-
|
|
206
|
-
it('is accessible when has a list', async () => {
|
|
207
|
-
const element = await listFixture()
|
|
208
|
-
await assert.isAccessible(element)
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
it('is accessible when active', async () => {
|
|
212
|
-
const element = await listFixture()
|
|
213
|
-
element.click()
|
|
214
|
-
await nextFrame()
|
|
215
|
-
await assert.isAccessible(element)
|
|
216
|
-
})
|
|
217
|
-
})
|
|
218
|
-
})
|
|
219
|
-
})
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import { fixture, assert, nextFrame, html, oneEvent } from '@open-wc/testing'
|
|
2
|
-
import sinon from 'sinon'
|
|
3
|
-
import type UiCollapse from '../../../src/md/collapse/internals/Collapse.js'
|
|
4
|
-
import '../../../src/md/collapse/ui-collapse.js'
|
|
5
|
-
|
|
6
|
-
describe('UiCollapse', () => {
|
|
7
|
-
async function basicFixture(): Promise<UiCollapse> {
|
|
8
|
-
return fixture(
|
|
9
|
-
html`<ui-collapse open>
|
|
10
|
-
<div style="height:100px;">Lorem ipsum</div>
|
|
11
|
-
</ui-collapse>`
|
|
12
|
-
)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async function emptyFixture(): Promise<UiCollapse> {
|
|
16
|
-
return fixture(html`<ui-collapse open></ui-collapse>`)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async function horizontalFixture(): Promise<UiCollapse> {
|
|
20
|
-
return fixture(
|
|
21
|
-
html`<ui-collapse open horizontal>
|
|
22
|
-
<div style="width:100px;">Lorem ipsum</div>
|
|
23
|
-
</ui-collapse>`
|
|
24
|
-
)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
describe('constructor', () => {
|
|
28
|
-
let collapse: UiCollapse
|
|
29
|
-
|
|
30
|
-
beforeEach(async () => {
|
|
31
|
-
collapse = await basicFixture()
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
it('open attribute', () => {
|
|
35
|
-
assert.equal(collapse.open, true)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
it('animated by default', () => {
|
|
39
|
-
assert.notOk(collapse.noAnimation, '`noAnimation` is false')
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
it('not transitioning on attached', () => {
|
|
43
|
-
assert.isFalse(collapse.transitioning, '`transitioning` is false')
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it('horizontal attribute', () => {
|
|
47
|
-
assert.equal(collapse.horizontal, false)
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it('default opened height', () => {
|
|
51
|
-
assert.equal(collapse.style.maxHeight, '')
|
|
52
|
-
})
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
describe('#open', () => {
|
|
56
|
-
let collapse: UiCollapse
|
|
57
|
-
let collapseHeight: string
|
|
58
|
-
|
|
59
|
-
beforeEach(async () => {
|
|
60
|
-
collapse = await basicFixture()
|
|
61
|
-
collapseHeight = getComputedStyle(collapse).height
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
it('set open to false triggers animation', async () => {
|
|
65
|
-
collapse.open = false
|
|
66
|
-
await collapse.updateComplete
|
|
67
|
-
// Animation got enabled.
|
|
68
|
-
assert.notEqual(collapse.style.transitionDuration, '0s')
|
|
69
|
-
assert.equal(collapse.transitioning, true, 'transitioning became true')
|
|
70
|
-
await oneEvent(collapse, 'transitionend')
|
|
71
|
-
assert.equal(collapse.style.transitionDuration, '0s')
|
|
72
|
-
assert.equal(collapse.transitioning, false, 'transitioning became false')
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
it('set open to false, then to true', async () => {
|
|
76
|
-
// Trigger 1st toggle.
|
|
77
|
-
collapse.open = false
|
|
78
|
-
await oneEvent(collapse, 'transitionend')
|
|
79
|
-
// Check if size is 0px.
|
|
80
|
-
assert.equal(collapse.style.maxHeight, '0px')
|
|
81
|
-
collapse.open = true
|
|
82
|
-
await collapse.updateComplete
|
|
83
|
-
assert.equal(collapse.style.maxHeight, collapseHeight)
|
|
84
|
-
await oneEvent(collapse, 'transitionend')
|
|
85
|
-
// Check finalSize after animation is done.
|
|
86
|
-
assert.equal(collapse.style.height, '')
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
it('open change trigger resize', async () => {
|
|
90
|
-
// No animations for faster test.
|
|
91
|
-
collapse.noAnimation = true
|
|
92
|
-
collapse.open = false
|
|
93
|
-
await oneEvent(collapse, 'resize')
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
it('overflow is hidden while animating', async () => {
|
|
97
|
-
assert.equal(getComputedStyle(collapse).overflow, 'visible')
|
|
98
|
-
collapse.open = false
|
|
99
|
-
await collapse.updateComplete
|
|
100
|
-
assert.equal(getComputedStyle(collapse).overflow, 'hidden')
|
|
101
|
-
await oneEvent(collapse, 'transitionend')
|
|
102
|
-
// Should still be hidden.
|
|
103
|
-
assert.equal(getComputedStyle(collapse).overflow, 'hidden')
|
|
104
|
-
})
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
describe('#transitioning', () => {
|
|
108
|
-
let collapse: UiCollapse
|
|
109
|
-
|
|
110
|
-
beforeEach(async () => {
|
|
111
|
-
collapse = await basicFixture()
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
it('updates only during transitions between open/close states', async () => {
|
|
115
|
-
const spy = sinon.spy()
|
|
116
|
-
|
|
117
|
-
collapse.addEventListener('transitioning', spy)
|
|
118
|
-
collapse.noAnimation = true
|
|
119
|
-
assert.equal(spy.callCount, 0, 'transitioning not affected by noAnimation')
|
|
120
|
-
collapse.horizontal = true
|
|
121
|
-
await collapse.updateComplete
|
|
122
|
-
assert.equal(spy.callCount, 1, 'transitioning affected by horizontal')
|
|
123
|
-
collapse.open = false
|
|
124
|
-
await collapse.updateComplete
|
|
125
|
-
assert.equal(spy.callCount, 3, 'transitioning changed 3 times')
|
|
126
|
-
assert.equal(collapse.transitioning, false, 'transitioning is false')
|
|
127
|
-
})
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
describe('#noAnimation', () => {
|
|
131
|
-
let collapse: UiCollapse
|
|
132
|
-
|
|
133
|
-
beforeEach(async () => {
|
|
134
|
-
collapse = await basicFixture()
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
it('disables animations', async () => {
|
|
138
|
-
collapse.noAnimation = true
|
|
139
|
-
// trying to animate the size update
|
|
140
|
-
collapse.open = false
|
|
141
|
-
await collapse.updateComplete
|
|
142
|
-
// Animation immediately disabled.
|
|
143
|
-
assert.equal(collapse.style.maxHeight, '0px')
|
|
144
|
-
})
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
describe('#horizontal', () => {
|
|
148
|
-
let collapse: UiCollapse
|
|
149
|
-
let collapseWidth: string
|
|
150
|
-
|
|
151
|
-
beforeEach(async () => {
|
|
152
|
-
collapse = await horizontalFixture()
|
|
153
|
-
collapseWidth = getComputedStyle(collapse).width
|
|
154
|
-
})
|
|
155
|
-
|
|
156
|
-
it('opened attribute', () => {
|
|
157
|
-
assert.equal(collapse.open, true)
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
it('horizontal attribute', () => {
|
|
161
|
-
assert.equal(collapse.horizontal, true)
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
it('default opened width', () => {
|
|
165
|
-
assert.equal(collapse.style.width, '')
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
it('set opened to false, then to true', async () => {
|
|
169
|
-
// Trigger 1st toggle.
|
|
170
|
-
collapse.open = false
|
|
171
|
-
await collapse.updateComplete
|
|
172
|
-
// Size should be immediately set.
|
|
173
|
-
assert.equal(collapse.style.maxWidth, '0px', 'maxWidth is set')
|
|
174
|
-
await oneEvent(collapse, 'transitionend')
|
|
175
|
-
|
|
176
|
-
// Check if size is still 0px.
|
|
177
|
-
assert.equal(collapse.style.maxWidth, '0px', 'maxWidth is still set')
|
|
178
|
-
// Trigger 2nd toggle.
|
|
179
|
-
collapse.open = true
|
|
180
|
-
await collapse.updateComplete
|
|
181
|
-
assert.equal(collapse.style.maxWidth, collapseWidth, 'maxWidth is set to the collapse width')
|
|
182
|
-
|
|
183
|
-
await oneEvent(collapse, 'transitionend')
|
|
184
|
-
assert.equal(collapse.style.width, '')
|
|
185
|
-
})
|
|
186
|
-
})
|
|
187
|
-
|
|
188
|
-
describe('No content', () => {
|
|
189
|
-
let collapse: UiCollapse
|
|
190
|
-
|
|
191
|
-
beforeEach(async () => {
|
|
192
|
-
collapse = await emptyFixture()
|
|
193
|
-
})
|
|
194
|
-
|
|
195
|
-
it('empty&opened shows dynamically loaded content', async () => {
|
|
196
|
-
await nextFrame()
|
|
197
|
-
collapse.toggle()
|
|
198
|
-
collapse.toggle()
|
|
199
|
-
assert.equal(collapse.style.maxHeight, '')
|
|
200
|
-
})
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
describe('a11y', () => {
|
|
204
|
-
async function a11yFixture(): Promise<UiCollapse> {
|
|
205
|
-
return fixture(
|
|
206
|
-
html`<ui-collapse id="collapse" tabindex="0">
|
|
207
|
-
<div>
|
|
208
|
-
Forma temperiemque cornua sidera dissociata cornua recessit innabilis ligavit: solidumque coeptis nullus
|
|
209
|
-
caelum sponte phoebe di regat mentisque tanta austro capacius amphitrite sui quin postquam semina fossae
|
|
210
|
-
liquidum umor galeae coeptis caligine liberioris quin liquidum matutinis invasit posset: flexi glomeravit
|
|
211
|
-
radiis certis invasit oppida postquam onerosior inclusum dominari opifex terris pace finxit quam aquae nunc
|
|
212
|
-
sine altae auroram quam habentem homo totidemque scythiam in pondus ensis tegit caecoque poena lapidosos
|
|
213
|
-
humanas coeperunt poena aetas totidem nec natura aethera locavit caelumque distinxit animalibus phoebe
|
|
214
|
-
cingebant moderantum porrexerat terrae possedit sua sole diu summaque obliquis melioris orbem
|
|
215
|
-
</div>
|
|
216
|
-
</ui-collapse>`
|
|
217
|
-
)
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
let collapse: UiCollapse
|
|
221
|
-
|
|
222
|
-
beforeEach(async () => {
|
|
223
|
-
// Force focus on body at every test.
|
|
224
|
-
document.body.focus()
|
|
225
|
-
collapse = await a11yFixture()
|
|
226
|
-
})
|
|
227
|
-
|
|
228
|
-
it('aria attributes', () => {
|
|
229
|
-
assert.equal(collapse.getAttribute('role'), 'group')
|
|
230
|
-
assert.equal(collapse.getAttribute('aria-hidden'), 'true')
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
it('set opened to true', async () => {
|
|
234
|
-
collapse.open = true
|
|
235
|
-
await collapse.updateComplete
|
|
236
|
-
assert.equal(collapse.getAttribute('aria-hidden'), 'false')
|
|
237
|
-
})
|
|
238
|
-
|
|
239
|
-
it('focus the collapse when opened', async () => {
|
|
240
|
-
assert.notEqual(document.activeElement, collapse)
|
|
241
|
-
collapse.open = true
|
|
242
|
-
await collapse.updateComplete
|
|
243
|
-
assert.equal(document.activeElement, collapse)
|
|
244
|
-
})
|
|
245
|
-
|
|
246
|
-
it('passes automated tests when closed', async () => {
|
|
247
|
-
await assert.isAccessible(collapse)
|
|
248
|
-
})
|
|
249
|
-
})
|
|
250
|
-
})
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { fixture, assert, html } from '@open-wc/testing'
|
|
2
|
-
import sinon from 'sinon'
|
|
3
|
-
import type UiCollapse from '../../../src/md/collapse/internals/Collapse.js'
|
|
4
|
-
import '../../../src/md/collapse/ui-collapse.js'
|
|
5
|
-
|
|
6
|
-
describe('UiCollapse: Flex layout', () => {
|
|
7
|
-
async function basicFixture(): Promise<UiCollapse> {
|
|
8
|
-
return fixture(
|
|
9
|
-
html` <div id="container" style="height: 200px; display: flex;">
|
|
10
|
-
<ui-collapse id="collapse" open style="flex: 1 0 auto">
|
|
11
|
-
<div style="height:100px;">Lorem ipsum</div>
|
|
12
|
-
</ui-collapse>
|
|
13
|
-
</div>`
|
|
14
|
-
)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
let container: HTMLElement
|
|
18
|
-
let collapse: UiCollapse
|
|
19
|
-
let collapseHeight: string
|
|
20
|
-
|
|
21
|
-
beforeEach(async () => {
|
|
22
|
-
container = await basicFixture()
|
|
23
|
-
collapse = container.querySelector('ui-collapse')!
|
|
24
|
-
collapseHeight = getComputedStyle(collapse).height
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
it('default opened height', () => {
|
|
28
|
-
assert.equal(collapse.style.height, '')
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it.skip('set opened to false triggers animation', (done) => {
|
|
32
|
-
collapse.open = false
|
|
33
|
-
// Animation got enabled.
|
|
34
|
-
collapse.addEventListener('transitionend', () => {
|
|
35
|
-
// Animation disabled.
|
|
36
|
-
assert.equal(collapse.style.transitionDuration, '0s')
|
|
37
|
-
done()
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('noAnimation disables animations', async () => {
|
|
42
|
-
collapse.noAnimation = true
|
|
43
|
-
// trying to animate the size update
|
|
44
|
-
collapse.open = false
|
|
45
|
-
await collapse.updateComplete
|
|
46
|
-
// Animation immediately disabled.
|
|
47
|
-
assert.equal(collapse.style.maxHeight, '0px')
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it.skip('set opened to false, then to true', (done) => {
|
|
51
|
-
// this listener will be triggered twice (every time `opened` changes)
|
|
52
|
-
collapse.addEventListener('transitionend', () => {
|
|
53
|
-
if (collapse.open) {
|
|
54
|
-
// Check finalSize after animation is done.
|
|
55
|
-
assert.equal(collapse.style.maxHeight, '')
|
|
56
|
-
done()
|
|
57
|
-
} else {
|
|
58
|
-
// Check if size is still 0px.
|
|
59
|
-
assert.equal(collapse.style.maxHeight, '0px')
|
|
60
|
-
// Trigger 2nd toggle.
|
|
61
|
-
collapse.toggle()
|
|
62
|
-
// Size should be immediately set.
|
|
63
|
-
assert.equal(collapse.style.maxHeight, collapseHeight)
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
// Trigger 1st toggle.
|
|
67
|
-
collapse.open = false
|
|
68
|
-
// Size should be immediately set.
|
|
69
|
-
assert.equal(collapse.style.maxHeight, '0px')
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
it('opened changes trigger resize', async () => {
|
|
73
|
-
const spy = sinon.stub()
|
|
74
|
-
collapse.addEventListener('resize', spy)
|
|
75
|
-
// No animations for faster test.
|
|
76
|
-
collapse.noAnimation = true
|
|
77
|
-
collapse.open = false
|
|
78
|
-
await collapse.updateComplete
|
|
79
|
-
assert.isTrue(spy.calledOnce, 'resize was fired')
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
it.skip('overflow is hidden while animating', (done) => {
|
|
83
|
-
collapse.addEventListener('transitionend', () => {
|
|
84
|
-
// Should still be hidden.
|
|
85
|
-
assert.equal(getComputedStyle(collapse).overflow, 'hidden')
|
|
86
|
-
done()
|
|
87
|
-
})
|
|
88
|
-
assert.equal(getComputedStyle(collapse).overflow, 'visible')
|
|
89
|
-
collapse.open = false
|
|
90
|
-
// Immediately updated style.
|
|
91
|
-
assert.equal(getComputedStyle(collapse).overflow, 'hidden')
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
it.skip('toggle horizontal updates size', () => {
|
|
95
|
-
collapse.horizontal = false
|
|
96
|
-
assert.equal(collapse.style.width, '')
|
|
97
|
-
assert.equal(collapse.style.maxHeight, '')
|
|
98
|
-
assert.equal(collapse.style.transitionProperty, 'max-height')
|
|
99
|
-
|
|
100
|
-
collapse.horizontal = true
|
|
101
|
-
assert.equal(collapse.style.maxWidth, '')
|
|
102
|
-
assert.equal(collapse.style.height, '')
|
|
103
|
-
assert.equal(collapse.style.transitionProperty, 'max-width')
|
|
104
|
-
})
|
|
105
|
-
})
|