@muonic/muon 0.0.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nycrc +17 -0
- package/.versionrc +3 -0
- package/CHANGELOG.md +389 -0
- package/components/card/index.js +1 -0
- package/components/card/src/card-component.js +43 -0
- package/components/card/src/card-styles.css +25 -0
- package/components/card/src/config-tokens.json +11 -0
- package/components/card/src/design-tokens.json +34 -0
- package/components/card/story.js +52 -0
- package/components/cta/index.js +1 -0
- package/components/cta/src/config-tokens.json +11 -0
- package/components/cta/src/cta-component.js +174 -0
- package/components/cta/src/cta-styles.css +105 -0
- package/components/cta/src/design-tokens.json +132 -0
- package/components/cta/story.js +99 -0
- package/components/detail/index.js +1 -0
- package/components/detail/src/config-tokens.json +11 -0
- package/components/detail/src/design-tokens.json +102 -0
- package/components/detail/src/detail-component.js +27 -0
- package/components/detail/src/detail-styles.css +83 -0
- package/components/detail/story.js +33 -0
- package/components/form/index.js +1 -0
- package/components/form/src/config-tokens.json +11 -0
- package/components/form/src/design-tokens.json +9 -0
- package/components/form/src/form-component.js +197 -0
- package/components/form/src/form-styles.css +10 -0
- package/components/form/story.js +71 -0
- package/components/icon/index.js +1 -0
- package/components/icon/src/config-tokens.json +31 -0
- package/components/icon/src/design-tokens.json +8 -0
- package/components/icon/src/icon-component.js +91 -0
- package/components/icon/src/icon-styles.css +26 -0
- package/components/icon/story.js +26 -0
- package/components/image/index.js +1 -0
- package/components/image/src/config-tokens.json +26 -0
- package/components/image/src/image-component.js +96 -0
- package/components/image/src/image-styles.css +71 -0
- package/components/image/story.js +31 -0
- package/components/inputter/index.js +1 -0
- package/components/inputter/src/config-tokens.json +14 -0
- package/components/inputter/src/design-tokens.json +308 -0
- package/components/inputter/src/inputter-component.js +227 -0
- package/components/inputter/src/inputter-styles-detail.css +59 -0
- package/components/inputter/src/inputter-styles.css +305 -0
- package/components/inputter/src/inputter-styles.slotted.css +64 -0
- package/components/inputter/story.js +243 -0
- package/css/accessibility.css +3 -0
- package/css/default.css +9 -0
- package/css/global.css +8 -0
- package/directives/image-loader-directive.js +116 -0
- package/directives/svg-loader-directive.js +94 -0
- package/index.js +52 -0
- package/mixins/card-mixin.js +27 -0
- package/mixins/detail-mixin.js +128 -0
- package/mixins/form-associate-mixin.js +36 -0
- package/mixins/form-element-mixin.js +378 -0
- package/mixins/image-holder-mixin.js +20 -0
- package/mixins/mask-mixin.js +159 -0
- package/mixins/validation-mixin.js +272 -0
- package/muon-element/index.js +97 -0
- package/package.json +72 -0
- package/rollup.config.mjs +30 -0
- package/scripts/build/storybook/index.mjs +11 -0
- package/scripts/build/storybook/run.mjs +47 -0
- package/scripts/rollup-plugins.mjs +116 -0
- package/scripts/serve/index.mjs +11 -0
- package/scripts/serve/run.mjs +27 -0
- package/scripts/style-dictionary.mjs +64 -0
- package/scripts/utils/config.mjs +30 -0
- package/scripts/utils/index.mjs +283 -0
- package/storybook/find-stories.js +36 -0
- package/storybook/server.config.mjs +19 -0
- package/storybook/stories.js +86 -0
- package/storybook/tokens/color.js +87 -0
- package/storybook/tokens/font.js +52 -0
- package/storybook/tokens/spacer.js +48 -0
- package/tests/README.md +3 -0
- package/tests/components/card/__snapshots__/card.test.snap.js +70 -0
- package/tests/components/card/card.test.js +81 -0
- package/tests/components/cta/__snapshots__/cta.test.snap.js +246 -0
- package/tests/components/cta/cta.test.js +212 -0
- package/tests/components/form/__snapshots__/form.test.snap.js +115 -0
- package/tests/components/form/form.test.js +336 -0
- package/tests/components/icon/__snapshots__/icon.test.snap.js +95 -0
- package/tests/components/icon/icon.test.js +197 -0
- package/tests/components/image/__snapshots__/image.test.snap.js +205 -0
- package/tests/components/image/image.test.js +314 -0
- package/tests/components/image/images/15.png +0 -0
- package/tests/components/image/images/150.png +0 -0
- package/tests/components/inputter/__snapshots__/inputter.test.snap.js +357 -0
- package/tests/components/inputter/inputter.test.js +427 -0
- package/tests/helpers/index.js +30 -0
- package/tests/mixins/__snapshots__/card.test.snap.js +35 -0
- package/tests/mixins/__snapshots__/detail.test.snap.js +237 -0
- package/tests/mixins/__snapshots__/form-element.test.snap.js +137 -0
- package/tests/mixins/__snapshots__/mask.test.snap.js +53 -0
- package/tests/mixins/__snapshots__/validation.test.snap.js +297 -0
- package/tests/mixins/card.test.js +63 -0
- package/tests/mixins/detail.test.js +223 -0
- package/tests/mixins/form-element.test.js +473 -0
- package/tests/mixins/mask.test.js +261 -0
- package/tests/mixins/muon-element.test.js +52 -0
- package/tests/mixins/validation.test.js +423 -0
- package/tests/runner/commands.mjs +19 -0
- package/tests/scripts/utils/card-component.js +26 -0
- package/tests/scripts/utils/muon.config.test.json +13 -0
- package/tests/scripts/utils/single.component.config.json +5 -0
- package/tests/scripts/utils/test-runner.mjs +1 -0
- package/tests/scripts/utils/utils-test.mjs +284 -0
- package/tests/utils/validation.functions.test.js +199 -0
- package/tokens/theme/color.json +482 -0
- package/tokens/theme/font.json +61 -0
- package/tokens/theme/size.json +27 -0
- package/tokens/theme/spacer.json +73 -0
- package/tokens/utils/formats/reference.js +17 -0
- package/tokens/utils/modular-scale.js +33 -0
- package/tokens/utils/templates/font-face.css.template +30 -0
- package/tokens/utils/transforms/color.js +27 -0
- package/tokens/utils/transforms/string.js +6 -0
- package/tokens/utils/validation.json +76 -0
- package/utils/scroll/index.js +31 -0
- package/utils/validation/index.js +205 -0
- package/web-test-runner.browserstack.config.mjs +123 -0
- package/web-test-runner.config.mjs +44 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/* @web/test-runner snapshot v1 */
|
|
2
|
+
export const snapshots = {};
|
|
3
|
+
|
|
4
|
+
snapshots["form implements standard self [with form]"] =
|
|
5
|
+
`<slot>
|
|
6
|
+
</slot>
|
|
7
|
+
`;
|
|
8
|
+
/* end snapshot form implements standard self [with form] */
|
|
9
|
+
|
|
10
|
+
snapshots["form form with submit button"] =
|
|
11
|
+
`<slot>
|
|
12
|
+
</slot>
|
|
13
|
+
`;
|
|
14
|
+
/* end snapshot form form with submit button */
|
|
15
|
+
|
|
16
|
+
snapshots["form form with submit input"] =
|
|
17
|
+
`<slot>
|
|
18
|
+
</slot>
|
|
19
|
+
`;
|
|
20
|
+
/* end snapshot form form with submit input */
|
|
21
|
+
|
|
22
|
+
snapshots["form form with reset button"] =
|
|
23
|
+
`<slot>
|
|
24
|
+
</slot>
|
|
25
|
+
`;
|
|
26
|
+
/* end snapshot form form with reset button */
|
|
27
|
+
|
|
28
|
+
snapshots["form form with reset input"] =
|
|
29
|
+
`<slot>
|
|
30
|
+
</slot>
|
|
31
|
+
`;
|
|
32
|
+
/* end snapshot form form with reset input */
|
|
33
|
+
|
|
34
|
+
snapshots["form form submitting"] =
|
|
35
|
+
`<slot>
|
|
36
|
+
</slot>
|
|
37
|
+
`;
|
|
38
|
+
/* end snapshot form form submitting */
|
|
39
|
+
|
|
40
|
+
snapshots["form form button disabled submitting"] =
|
|
41
|
+
`<slot>
|
|
42
|
+
</slot>
|
|
43
|
+
`;
|
|
44
|
+
/* end snapshot form form button disabled submitting */
|
|
45
|
+
|
|
46
|
+
snapshots["form form submitting validation"] =
|
|
47
|
+
`<div class="form">
|
|
48
|
+
<slot>
|
|
49
|
+
</slot>
|
|
50
|
+
</div>
|
|
51
|
+
`;
|
|
52
|
+
/* end snapshot form form submitting validation */
|
|
53
|
+
|
|
54
|
+
snapshots["form form submitting with input"] =
|
|
55
|
+
`<slot>
|
|
56
|
+
</slot>
|
|
57
|
+
`;
|
|
58
|
+
/* end snapshot form form submitting with input */
|
|
59
|
+
|
|
60
|
+
snapshots["form form submitting with inputter"] =
|
|
61
|
+
`<slot>
|
|
62
|
+
</slot>
|
|
63
|
+
`;
|
|
64
|
+
/* end snapshot form form submitting with inputter */
|
|
65
|
+
|
|
66
|
+
snapshots["form form submitting with inputter parent"] =
|
|
67
|
+
`<slot>
|
|
68
|
+
</slot>
|
|
69
|
+
`;
|
|
70
|
+
/* end snapshot form form submitting with inputter parent */
|
|
71
|
+
|
|
72
|
+
snapshots["form form with reset cta"] =
|
|
73
|
+
`<slot>
|
|
74
|
+
</slot>
|
|
75
|
+
`;
|
|
76
|
+
/* end snapshot form form with reset cta */
|
|
77
|
+
|
|
78
|
+
snapshots["form form with submit cta"] =
|
|
79
|
+
`<slot>
|
|
80
|
+
</slot>
|
|
81
|
+
`;
|
|
82
|
+
/* end snapshot form form with submit cta */
|
|
83
|
+
|
|
84
|
+
snapshots["form form button loading submitting"] =
|
|
85
|
+
`<div class="form">
|
|
86
|
+
<slot>
|
|
87
|
+
</slot>
|
|
88
|
+
</div>
|
|
89
|
+
`;
|
|
90
|
+
/* end snapshot form form button loading submitting */
|
|
91
|
+
|
|
92
|
+
snapshots["form form cta loading submitting"] =
|
|
93
|
+
`<slot>
|
|
94
|
+
</slot>
|
|
95
|
+
`;
|
|
96
|
+
/* end snapshot form form cta loading submitting */
|
|
97
|
+
|
|
98
|
+
snapshots["form form cta loading reset"] =
|
|
99
|
+
`<slot>
|
|
100
|
+
</slot>
|
|
101
|
+
`;
|
|
102
|
+
/* end snapshot form form cta loading reset */
|
|
103
|
+
|
|
104
|
+
snapshots["form form submitting with inputter [validate]"] =
|
|
105
|
+
`<slot>
|
|
106
|
+
</slot>
|
|
107
|
+
`;
|
|
108
|
+
/* end snapshot form form submitting with inputter [validate] */
|
|
109
|
+
|
|
110
|
+
snapshots["form form cta reset with inputter"] =
|
|
111
|
+
`<slot>
|
|
112
|
+
</slot>
|
|
113
|
+
`;
|
|
114
|
+
/* end snapshot form form cta reset with inputter */
|
|
115
|
+
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/* eslint-disable no-undef */
|
|
2
|
+
import { expect, fixture, html, defineCE, unsafeStatic } from '@open-wc/testing';
|
|
3
|
+
import sinon from 'sinon';
|
|
4
|
+
import { defaultChecks } from '../../helpers';
|
|
5
|
+
import { Form } from '@muonic/muon/components/form';
|
|
6
|
+
import { Inputter } from '@muonic/muon/components/inputter';
|
|
7
|
+
import { Cta } from '@muonic/muon/components/cta';
|
|
8
|
+
|
|
9
|
+
const tagName = defineCE(Form);
|
|
10
|
+
const tag = unsafeStatic(tagName);
|
|
11
|
+
|
|
12
|
+
const inputterTagName = defineCE(Inputter);
|
|
13
|
+
const inputterTag = unsafeStatic(inputterTagName);
|
|
14
|
+
|
|
15
|
+
const ctaTagName = defineCE(Cta);
|
|
16
|
+
const ctaTag = unsafeStatic(ctaTagName);
|
|
17
|
+
|
|
18
|
+
describe('form', () => {
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
sinon.restore();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('implements standard self [no form]', () => {
|
|
24
|
+
const el = new Form();
|
|
25
|
+
const message = 'No form node found. Did you put a <form> element inside?';
|
|
26
|
+
expect(() => el.__checkForFormEl()).to.throw(message, 'no `form` added');
|
|
27
|
+
expect(() => el._reset()).to.throw(message, 'no `form` added for reset');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('implements standard self [with form]', async () => {
|
|
31
|
+
const el = await fixture(html`<${tag}><form></form></${tag}>`);
|
|
32
|
+
await defaultChecks(el);
|
|
33
|
+
|
|
34
|
+
const shadowRoot = el.shadowRoot;
|
|
35
|
+
const slot = shadowRoot.querySelector('slot');
|
|
36
|
+
const hiddenSubmit = el.querySelector('input[hidden][type="submit"]');
|
|
37
|
+
|
|
38
|
+
expect(el.type).to.equal('standard', '`type` property has default value `standard`');
|
|
39
|
+
expect(el._submitButton).to.equal(null, 'no `submit` button added');
|
|
40
|
+
expect(el._resetButton).to.equal(null, 'no `reset` button added');
|
|
41
|
+
expect(slot).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
42
|
+
expect(hiddenSubmit).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
43
|
+
expect(el._nativeForm).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('form with submit button', async () => {
|
|
47
|
+
const el = await fixture(html`<${tag}><form><button type="submit">submit</button></form></${tag}>`);
|
|
48
|
+
await defaultChecks(el);
|
|
49
|
+
|
|
50
|
+
const shadowRoot = el.shadowRoot;
|
|
51
|
+
const slot = shadowRoot.querySelector('slot');
|
|
52
|
+
const hiddenSubmit = el.querySelector('input[hidden][type="submit"]');
|
|
53
|
+
|
|
54
|
+
expect(el.type).to.equal('standard', '`type` property has default value `standard`');
|
|
55
|
+
expect(el._submitButton.nodeName).to.equal('BUTTON', 'has submit button');
|
|
56
|
+
expect(el._submitButton.type).to.equal('submit', 'has submit type button');
|
|
57
|
+
expect(el._resetButton).to.equal(null, 'no `reset` button added');
|
|
58
|
+
expect(slot).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
59
|
+
expect(hiddenSubmit).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('form with submit cta', async () => {
|
|
63
|
+
const el = await fixture(html`<${tag}><form><${ctaTag} type="submit">submit</${ctaTag}></form></${tag}>`);
|
|
64
|
+
await defaultChecks(el);
|
|
65
|
+
|
|
66
|
+
const shadowRoot = el.shadowRoot;
|
|
67
|
+
const slot = shadowRoot.querySelector('slot');
|
|
68
|
+
const hiddenSubmit = el.querySelector('input[hidden][type="submit"]');
|
|
69
|
+
|
|
70
|
+
expect(el.type).to.equal('standard', '`type` property has default value `standard`');
|
|
71
|
+
expect(el._submitButton.nodeName.toLowerCase()).to.equal(ctaTagName, 'has submit cta');
|
|
72
|
+
expect(el._submitButton.type).to.equal('submit', 'has submit type button');
|
|
73
|
+
expect(el._resetButton).to.equal(null, 'no `reset` cta added');
|
|
74
|
+
expect(slot).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
75
|
+
expect(hiddenSubmit).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('form with submit input', async () => {
|
|
79
|
+
const el = await fixture(html`<${tag}><form><input type="submit">submit</input></form></${tag}>`);
|
|
80
|
+
await defaultChecks(el);
|
|
81
|
+
|
|
82
|
+
const shadowRoot = el.shadowRoot;
|
|
83
|
+
const slot = shadowRoot.querySelector('slot');
|
|
84
|
+
const hiddenSubmit = el.querySelector('input[hidden][type="submit"]');
|
|
85
|
+
|
|
86
|
+
expect(el.type).to.equal('standard', '`type` property has default value `standard`');
|
|
87
|
+
expect(el._submitButton.nodeName).to.equal('INPUT', 'has submit input');
|
|
88
|
+
expect(el._submitButton.type).to.equal('submit', 'has submit type input');
|
|
89
|
+
expect(el._resetButton).to.equal(null, 'no `reset` button added');
|
|
90
|
+
expect(slot).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
91
|
+
expect(hiddenSubmit).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('form with reset button', async () => {
|
|
95
|
+
const el = await fixture(html`<${tag}><form><button type="reset">reset</button></form></${tag}>`);
|
|
96
|
+
await defaultChecks(el);
|
|
97
|
+
|
|
98
|
+
const shadowRoot = el.shadowRoot;
|
|
99
|
+
const slot = shadowRoot.querySelector('slot');
|
|
100
|
+
const hiddenSubmit = el.querySelector('input[hidden][type="submit"]');
|
|
101
|
+
|
|
102
|
+
expect(el.type).to.equal('standard', '`type` property has default value `standard`');
|
|
103
|
+
expect(el._resetButton.nodeName).to.equal('BUTTON', 'has reset button');
|
|
104
|
+
expect(el._resetButton.type).to.equal('reset', 'has reset type button');
|
|
105
|
+
expect(el._submitButton).to.equal(null, 'no `submit` button added');
|
|
106
|
+
expect(slot).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
107
|
+
expect(hiddenSubmit).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('form with reset cta', async () => {
|
|
111
|
+
const el = await fixture(html`<${tag}><form><${ctaTag} type="reset">reset</${ctaTag}></form></${tag}>`);
|
|
112
|
+
await defaultChecks(el);
|
|
113
|
+
|
|
114
|
+
const shadowRoot = el.shadowRoot;
|
|
115
|
+
const slot = shadowRoot.querySelector('slot');
|
|
116
|
+
const hiddenSubmit = el.querySelector('input[hidden][type="submit"]');
|
|
117
|
+
|
|
118
|
+
expect(el.type).to.equal('standard', '`type` property has default value `standard`');
|
|
119
|
+
expect(el._resetButton.nodeName.toLowerCase()).to.equal(ctaTagName, 'has reset cta');
|
|
120
|
+
expect(el._resetButton.type).to.equal('reset', 'has reset type button');
|
|
121
|
+
expect(el._submitButton).to.equal(null, 'no `submit` cta added');
|
|
122
|
+
expect(slot).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
123
|
+
expect(hiddenSubmit).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('form with reset input', async () => {
|
|
127
|
+
const el = await fixture(html`<${tag}><form><input type="reset">reset</input></form></${tag}>`);
|
|
128
|
+
await defaultChecks(el);
|
|
129
|
+
|
|
130
|
+
const shadowRoot = el.shadowRoot;
|
|
131
|
+
const slot = shadowRoot.querySelector('slot');
|
|
132
|
+
const hiddenSubmit = el.querySelector('input[hidden][type="submit"]');
|
|
133
|
+
|
|
134
|
+
expect(el.type).to.equal('standard', '`type` property has default value `standard`');
|
|
135
|
+
expect(el._resetButton.nodeName).to.equal('INPUT', 'has reset input');
|
|
136
|
+
expect(el._resetButton.type).to.equal('reset', 'has reset type input');
|
|
137
|
+
expect(el._submitButton).to.equal(null, 'no `submit` button added');
|
|
138
|
+
expect(slot).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
139
|
+
expect(hiddenSubmit).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('form submitting', async () => {
|
|
143
|
+
const submitSpy = sinon.spy();
|
|
144
|
+
const el = await fixture(html`<${tag} @submit=${submitSpy}><form><button type="submit">submit</button></form></${tag}>`);
|
|
145
|
+
const submitBtn = el.querySelector('button');
|
|
146
|
+
|
|
147
|
+
await defaultChecks(el);
|
|
148
|
+
|
|
149
|
+
submitBtn.click();
|
|
150
|
+
|
|
151
|
+
expect(submitSpy.callCount).to.equal(1);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('form submitting with input', async () => {
|
|
155
|
+
const submitSpy = sinon.spy();
|
|
156
|
+
const el = await fixture(html`<${tag} @submit=${submitSpy}><form><label for="foo">Bar</label><input id="foo" type="text" required /><button type="submit">submit</button></form></${tag}>`);
|
|
157
|
+
const submitBtn = el.querySelector('button');
|
|
158
|
+
|
|
159
|
+
await defaultChecks(el);
|
|
160
|
+
|
|
161
|
+
submitBtn.click();
|
|
162
|
+
|
|
163
|
+
expect(submitSpy.callCount).to.equal(0);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('form submitting with inputter [validate]', async () => {
|
|
167
|
+
const submitSpy = sinon.spy();
|
|
168
|
+
const el = await fixture(html`
|
|
169
|
+
<${tag} @submit=${submitSpy}>
|
|
170
|
+
<form>
|
|
171
|
+
<${inputterTag} validation='["isRequired"]' value="foo" name="bar">
|
|
172
|
+
<label slot="label" for="foo">Bar</label>
|
|
173
|
+
<input id="foo" type="text" />
|
|
174
|
+
</${inputterTag}>
|
|
175
|
+
<button type="submit">submit</button>
|
|
176
|
+
</form>
|
|
177
|
+
</${tag}>
|
|
178
|
+
`);
|
|
179
|
+
|
|
180
|
+
const inputter = document.querySelector(inputterTagName);
|
|
181
|
+
|
|
182
|
+
await defaultChecks(el);
|
|
183
|
+
|
|
184
|
+
expect(el.validate()).to.deep.equal(
|
|
185
|
+
{
|
|
186
|
+
isValid: true,
|
|
187
|
+
validationStates:
|
|
188
|
+
[
|
|
189
|
+
{
|
|
190
|
+
name: 'bar',
|
|
191
|
+
value: 'foo',
|
|
192
|
+
error: undefined,
|
|
193
|
+
isValid: true,
|
|
194
|
+
formElement: inputter,
|
|
195
|
+
validity: inputter.validity
|
|
196
|
+
}
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('form submitting with inputter', async () => {
|
|
203
|
+
const submitSpy = sinon.spy();
|
|
204
|
+
const el = await fixture(html`
|
|
205
|
+
<${tag} @submit=${submitSpy}>
|
|
206
|
+
<form>
|
|
207
|
+
<${inputterTag} validation='["isRequired"]'>
|
|
208
|
+
<label slot="label" for="foo">Bar</label>
|
|
209
|
+
<input id="foo" type="text" />
|
|
210
|
+
</${inputterTag}>
|
|
211
|
+
<button type="submit">submit</button>
|
|
212
|
+
</form>
|
|
213
|
+
</${tag}>
|
|
214
|
+
`);
|
|
215
|
+
const submitBtn = el.querySelector('button');
|
|
216
|
+
|
|
217
|
+
await defaultChecks(el);
|
|
218
|
+
|
|
219
|
+
submitBtn.click();
|
|
220
|
+
|
|
221
|
+
expect(submitSpy.callCount).to.equal(0);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('form submitting with inputter parent', async () => {
|
|
225
|
+
const submitSpy = sinon.spy();
|
|
226
|
+
const el = await fixture(html`
|
|
227
|
+
<${tag} @submit=${submitSpy}>
|
|
228
|
+
<form>
|
|
229
|
+
<${inputterTag} heading="foo" validation='["isRequired"]'>
|
|
230
|
+
<div>
|
|
231
|
+
<input type="checkbox" name="checkboxes" value="a" id="check-01">
|
|
232
|
+
<label for="check-01">Option A</label>
|
|
233
|
+
<input type="checkbox" name="checkboxes" value="b" id="check-02">
|
|
234
|
+
<label for="check-02">Option B</label>
|
|
235
|
+
</div>
|
|
236
|
+
</${inputterTag}>
|
|
237
|
+
<button type="submit">submit</button>
|
|
238
|
+
</form>
|
|
239
|
+
</${tag}>
|
|
240
|
+
`);
|
|
241
|
+
const submitBtn = el.querySelector('button');
|
|
242
|
+
|
|
243
|
+
await defaultChecks(el);
|
|
244
|
+
|
|
245
|
+
submitBtn.click();
|
|
246
|
+
|
|
247
|
+
expect(submitSpy.callCount).to.equal(0);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it('form button disabled submitting', async () => {
|
|
251
|
+
const submitSpy = sinon.spy();
|
|
252
|
+
const el = await fixture(html`<${tag} @submit=${submitSpy}><form><button disabled type="submit">submit</button></form></${tag}>`);
|
|
253
|
+
const submitBtn = el.querySelector('button');
|
|
254
|
+
|
|
255
|
+
await defaultChecks(el);
|
|
256
|
+
|
|
257
|
+
submitBtn.click();
|
|
258
|
+
|
|
259
|
+
expect(submitSpy.callCount).to.equal(0);
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('form cta loading submitting', async () => {
|
|
263
|
+
const submitSpy = sinon.spy();
|
|
264
|
+
const el = await fixture(html`<${tag} @submit=${submitSpy}><form><${ctaTag} loading type="submit">submit</${ctaTag}></form></${tag}>`);
|
|
265
|
+
const submitBtn = el.querySelector(ctaTagName);
|
|
266
|
+
|
|
267
|
+
await defaultChecks(el);
|
|
268
|
+
|
|
269
|
+
submitBtn.click();
|
|
270
|
+
|
|
271
|
+
expect(submitSpy.callCount).to.equal(0);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it('form with reset button', async () => {
|
|
275
|
+
const el = await fixture(html`<${tag}><form><label for="foo">Bar</label><input id="foo" type="text" value="foo" /><button type="reset">reset</button></form></${tag}>`);
|
|
276
|
+
const input = el.querySelector('input');
|
|
277
|
+
const resetBtn = el.querySelector('button');
|
|
278
|
+
|
|
279
|
+
await defaultChecks(el);
|
|
280
|
+
|
|
281
|
+
expect(input.value).to.equal('foo', 'default input value');
|
|
282
|
+
|
|
283
|
+
input.value = '';
|
|
284
|
+
|
|
285
|
+
expect(input.value).to.equal('', 'changed input value');
|
|
286
|
+
|
|
287
|
+
resetBtn.click();
|
|
288
|
+
|
|
289
|
+
expect(input.value).to.equal('foo', 'reset input value');
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it('form cta loading reset', async () => {
|
|
293
|
+
const submitSpy = sinon.spy();
|
|
294
|
+
const el = await fixture(html`<${tag} @submit=${submitSpy}><form><label for="foo">Bar</label><input id="foo" type="text" value="foo" /><${ctaTag} loading type="reset">submit</${ctaTag}></form></${tag}>`);
|
|
295
|
+
const input = el.querySelector('input');
|
|
296
|
+
const resetBtn = el.querySelector(ctaTagName);
|
|
297
|
+
|
|
298
|
+
await defaultChecks(el);
|
|
299
|
+
|
|
300
|
+
expect(input.value).to.equal('foo', 'default input value');
|
|
301
|
+
|
|
302
|
+
input.value = '';
|
|
303
|
+
|
|
304
|
+
expect(input.value).to.equal('', 'changed input value');
|
|
305
|
+
|
|
306
|
+
resetBtn.click();
|
|
307
|
+
|
|
308
|
+
expect(input.value).to.equal('foo', 'no reset input value');
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
it('form cta reset with inputter', async () => {
|
|
312
|
+
const submitSpy = sinon.spy();
|
|
313
|
+
const el = await fixture(html`
|
|
314
|
+
<${tag} @submit=${submitSpy}>
|
|
315
|
+
<form>
|
|
316
|
+
<${inputterTag} validation='["isRequired"]' value='test'>
|
|
317
|
+
<label slot="label" for="foo">Bar</label>
|
|
318
|
+
<input id="foo" type="text" />
|
|
319
|
+
</${inputterTag}>
|
|
320
|
+
<${ctaTag} type="reset">Reset</${ctaTag}>
|
|
321
|
+
</form>
|
|
322
|
+
</${tag}>
|
|
323
|
+
`);
|
|
324
|
+
const input = el.querySelector(inputterTagName);
|
|
325
|
+
const resetBtn = el.querySelector(ctaTagName);
|
|
326
|
+
|
|
327
|
+
await defaultChecks(el);
|
|
328
|
+
expect(input.value).to.equal('test', 'default input value');
|
|
329
|
+
|
|
330
|
+
input.value = '';
|
|
331
|
+
expect(input.value).to.equal('', 'changed input value');
|
|
332
|
+
|
|
333
|
+
resetBtn.click();
|
|
334
|
+
expect(input.value).to.equal('test', 'no reset input value');
|
|
335
|
+
});
|
|
336
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* @web/test-runner snapshot v1 */
|
|
2
|
+
export const snapshots = {};
|
|
3
|
+
|
|
4
|
+
snapshots["icon implements standard self"] =
|
|
5
|
+
`<div
|
|
6
|
+
aria-hidden="true"
|
|
7
|
+
class="icon standard"
|
|
8
|
+
style="--icon-size:100%;"
|
|
9
|
+
>
|
|
10
|
+
</div>
|
|
11
|
+
`;
|
|
12
|
+
/* end snapshot icon implements standard self */
|
|
13
|
+
|
|
14
|
+
snapshots["icon no anonymous slot"] =
|
|
15
|
+
`<div
|
|
16
|
+
aria-hidden="true"
|
|
17
|
+
class="icon standard"
|
|
18
|
+
style="--icon-size:100%;"
|
|
19
|
+
>
|
|
20
|
+
</div>
|
|
21
|
+
`;
|
|
22
|
+
/* end snapshot icon no anonymous slot */
|
|
23
|
+
|
|
24
|
+
snapshots["icon implements icon size"] =
|
|
25
|
+
`<div
|
|
26
|
+
aria-hidden="true"
|
|
27
|
+
class="icon standard"
|
|
28
|
+
style="--icon-size:16px;"
|
|
29
|
+
>
|
|
30
|
+
</div>
|
|
31
|
+
`;
|
|
32
|
+
/* end snapshot icon implements icon size */
|
|
33
|
+
|
|
34
|
+
snapshots["icon select icon name"] =
|
|
35
|
+
`<div
|
|
36
|
+
aria-hidden="true"
|
|
37
|
+
class="icon standard"
|
|
38
|
+
style="--icon-size:100%;"
|
|
39
|
+
>
|
|
40
|
+
</div>
|
|
41
|
+
`;
|
|
42
|
+
/* end snapshot icon select icon name */
|
|
43
|
+
|
|
44
|
+
snapshots["icon fails gracefully when using non existent type"] =
|
|
45
|
+
`<div
|
|
46
|
+
aria-hidden="true"
|
|
47
|
+
class="icon standard"
|
|
48
|
+
style="--icon-size:100%;"
|
|
49
|
+
>
|
|
50
|
+
</div>
|
|
51
|
+
`;
|
|
52
|
+
/* end snapshot icon fails gracefully when using non existent type */
|
|
53
|
+
|
|
54
|
+
snapshots["icon fails gracefully when using non existent name"] =
|
|
55
|
+
`<div
|
|
56
|
+
aria-hidden="true"
|
|
57
|
+
class="icon standard"
|
|
58
|
+
style="--icon-size:100%;"
|
|
59
|
+
>
|
|
60
|
+
</div>
|
|
61
|
+
`;
|
|
62
|
+
/* end snapshot icon fails gracefully when using non existent name */
|
|
63
|
+
|
|
64
|
+
snapshots["icon adds aria-label when describe used"] =
|
|
65
|
+
`<div
|
|
66
|
+
aria-label="foobar"
|
|
67
|
+
class="icon standard"
|
|
68
|
+
role="img"
|
|
69
|
+
style="--icon-size:100%;"
|
|
70
|
+
>
|
|
71
|
+
</div>
|
|
72
|
+
`;
|
|
73
|
+
/* end snapshot icon adds aria-label when describe used */
|
|
74
|
+
|
|
75
|
+
snapshots["icon adds attributes for when describe used"] =
|
|
76
|
+
`<div
|
|
77
|
+
aria-label="foobar"
|
|
78
|
+
class="icon standard"
|
|
79
|
+
role="img"
|
|
80
|
+
style="--icon-size:100%;"
|
|
81
|
+
>
|
|
82
|
+
</div>
|
|
83
|
+
`;
|
|
84
|
+
/* end snapshot icon adds attributes for when describe used */
|
|
85
|
+
|
|
86
|
+
snapshots["icon caches not available"] =
|
|
87
|
+
`<div
|
|
88
|
+
aria-hidden="true"
|
|
89
|
+
class="icon standard"
|
|
90
|
+
style="--icon-size:100%;"
|
|
91
|
+
>
|
|
92
|
+
</div>
|
|
93
|
+
`;
|
|
94
|
+
/* end snapshot icon caches not available */
|
|
95
|
+
|