@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,314 @@
|
|
|
1
|
+
/* eslint-disable no-undef */
|
|
2
|
+
import { expect, fixture, html, defineCE, unsafeStatic, nextFrame } from '@open-wc/testing';
|
|
3
|
+
import sinon from 'sinon';
|
|
4
|
+
import { defaultChecks } from '../../helpers';
|
|
5
|
+
import { Image } from '@muonic/muon/components/image';
|
|
6
|
+
|
|
7
|
+
const tagName = defineCE(Image);
|
|
8
|
+
const tag = unsafeStatic(tagName);
|
|
9
|
+
const imageURL = 'tests/components/image/images/150.png';
|
|
10
|
+
const thumbURL = 'tests/components/image/images/15.png';
|
|
11
|
+
|
|
12
|
+
const awaitLoading = () => {
|
|
13
|
+
return new Promise((resolve) => {
|
|
14
|
+
window.addEventListener('image-loaded', resolve);
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const awaitFailed = () => {
|
|
19
|
+
return new Promise((resolve) => {
|
|
20
|
+
window.addEventListener('image-failed', resolve);
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
describe('image', () => {
|
|
25
|
+
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
sinon.restore();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('implements standard self', async () => {
|
|
31
|
+
const el = await fixture(html`<${tag}></${tag}>`);
|
|
32
|
+
|
|
33
|
+
await defaultChecks(el);
|
|
34
|
+
|
|
35
|
+
const shadowRoot = el.shadowRoot;
|
|
36
|
+
const elementImage = shadowRoot.querySelector('.image');
|
|
37
|
+
|
|
38
|
+
expect(elementImage.innerHTML).to.equal('', 'has empty image div');
|
|
39
|
+
expect(el.src).to.equal(undefined, '`src` has no default property');
|
|
40
|
+
expect(el.type).to.equal('standard', '`type` property has default value `standard`');
|
|
41
|
+
expect(el._ratios).to.deep.equal(['1 / 1', '4 / 3', '16 / 9'], '`ratios` property has default token value');
|
|
42
|
+
expect(el.placeholder).to.equal('', '`placeholder` has default token value');
|
|
43
|
+
expect(el.ratio).to.equal('16 / 9', '`ratio` has default token value');
|
|
44
|
+
expect(el.loading).to.equal('lazy', '`loading` has default value');
|
|
45
|
+
expect(el.alt).to.equal('', 'alt has no value');
|
|
46
|
+
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('implements src image', async () => {
|
|
50
|
+
const el = await fixture(html`<${tag} src="${imageURL}"></${tag}>`);
|
|
51
|
+
|
|
52
|
+
await awaitLoading(el);
|
|
53
|
+
await defaultChecks(el);
|
|
54
|
+
|
|
55
|
+
const shadowRoot = el.shadowRoot;
|
|
56
|
+
const elementImage = shadowRoot.querySelector('.image');
|
|
57
|
+
const img = elementImage.querySelector('img');
|
|
58
|
+
|
|
59
|
+
expect(elementImage).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
60
|
+
expect(el.type).to.equal('standard', '`type` property has default value `standard`');
|
|
61
|
+
expect(el.ratio).to.equal('16 / 9', '`ratio` has default token value');
|
|
62
|
+
expect(img.src).to.include(imageURL, 'has `src` value from el');
|
|
63
|
+
expect(img.alt).to.equal('', 'alt has not value');
|
|
64
|
+
expect(Array.from(img.classList)).to.deep.equal(['blur-out', 'image-lazy']);
|
|
65
|
+
|
|
66
|
+
if (CSS.supports('aspect-ratio', '1 / 1')) {
|
|
67
|
+
expect(elementImage.style.getPropertyValue('--image-ratio')).to.equal('16 / 9', 'ratio passed as custom css variable');
|
|
68
|
+
expect(getComputedStyle(elementImage).aspectRatio).to.equal('16 / 9', 'computed style value added for aspect-ratio');
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('implements ratio', async () => {
|
|
73
|
+
const el = await fixture(html`<${tag} src="${imageURL}" ratio="1 / 1"></${tag}>`);
|
|
74
|
+
|
|
75
|
+
await awaitLoading(el);
|
|
76
|
+
await defaultChecks(el);
|
|
77
|
+
|
|
78
|
+
const shadowRoot = el.shadowRoot;
|
|
79
|
+
const elementImage = shadowRoot.querySelector('.image');
|
|
80
|
+
const img = elementImage.querySelector('img');
|
|
81
|
+
|
|
82
|
+
expect(elementImage).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
83
|
+
expect(el.type).to.equal('standard', '`type` property has default value `standard`');
|
|
84
|
+
expect(el.ratio).to.equal('1 / 1', '`ratio` has default token value');
|
|
85
|
+
expect(img.src).to.include(imageURL, 'has `src` value from el');
|
|
86
|
+
expect(img.alt).to.equal('', 'alt has not value');
|
|
87
|
+
expect(Array.from(img.classList)).to.deep.equal(['blur-out', 'image-lazy']);
|
|
88
|
+
|
|
89
|
+
if (CSS.supports('aspect-ratio', '1 / 1')) {
|
|
90
|
+
expect(elementImage.style.getPropertyValue('--image-ratio')).to.equal('1 / 1', 'ratio passed as custom css variable');
|
|
91
|
+
expect(getComputedStyle(elementImage).aspectRatio).to.equal('1 / 1', 'computed style value added for aspect-ratio');
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('implements background', async () => {
|
|
96
|
+
const el = await fixture(html`<${tag} src="${imageURL}" background></${tag}>`);
|
|
97
|
+
|
|
98
|
+
await awaitLoading(el);
|
|
99
|
+
await defaultChecks(el);
|
|
100
|
+
|
|
101
|
+
const shadowRoot = el.shadowRoot;
|
|
102
|
+
const elementImage = shadowRoot.querySelector('.image');
|
|
103
|
+
const img = elementImage.querySelector('img');
|
|
104
|
+
const holder = elementImage.querySelector('.image-holder');
|
|
105
|
+
|
|
106
|
+
expect(elementImage).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
107
|
+
expect(img).to.be.null; // eslint-disable-line no-unused-expressions
|
|
108
|
+
expect(el.type).to.equal('standard', '`type` property has default value `standard`');
|
|
109
|
+
expect(Array.from(holder.classList)).to.deep.equal(['image-holder', 'blur-out']);
|
|
110
|
+
expect(getComputedStyle(holder).backgroundImage).to.include(imageURL, 'computed style value added for background image');
|
|
111
|
+
expect(holder.style.getPropertyValue('--background-image')).to.include(imageURL, 'image passed as custom css variable');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('implements placeholder image', async () => {
|
|
115
|
+
const el = await fixture(html`<${tag} src="https://via.placeholder.com/35000" placeholder="${thumbURL}"></${tag}>`);
|
|
116
|
+
|
|
117
|
+
await awaitFailed();
|
|
118
|
+
await defaultChecks(el);
|
|
119
|
+
|
|
120
|
+
const shadowRoot = el.shadowRoot;
|
|
121
|
+
const elementImage = shadowRoot.querySelector('.image');
|
|
122
|
+
const img = elementImage.querySelector('img');
|
|
123
|
+
|
|
124
|
+
expect(elementImage).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
125
|
+
expect(el.type).to.equal('standard', '`type` property has default value `standard`');
|
|
126
|
+
expect(el.ratio).to.equal('16 / 9', '`ratio` has default token value');
|
|
127
|
+
expect(img.src).to.include(thumbURL, 'has `src` value from el');
|
|
128
|
+
expect(img.alt).to.equal('', 'alt has not value');
|
|
129
|
+
expect(Array.from(img.classList)).to.deep.equal(['image-lazy', 'blur']);
|
|
130
|
+
|
|
131
|
+
if (CSS.supports('aspect-ratio', '1 / 1')) {
|
|
132
|
+
expect(elementImage.style.getPropertyValue('--image-ratio')).to.equal('16 / 9', 'ratio passed as custom css variable');
|
|
133
|
+
expect(getComputedStyle(elementImage).aspectRatio).to.equal('16 / 9', 'computed style value added for aspect-ratio');
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('implements placeholder image for background', async () => {
|
|
138
|
+
const el = await fixture(html`<${tag} src="https://via.placeholder.com/35000" placeholder="${thumbURL}" background></${tag}>`);
|
|
139
|
+
await awaitFailed();
|
|
140
|
+
|
|
141
|
+
await defaultChecks(el);
|
|
142
|
+
|
|
143
|
+
const shadowRoot = el.shadowRoot;
|
|
144
|
+
const elementImage = shadowRoot.querySelector('.image');
|
|
145
|
+
const holder = elementImage.querySelector('.image-holder');
|
|
146
|
+
|
|
147
|
+
expect(elementImage).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
148
|
+
expect(el.type).to.equal('standard', '`type` property has default value `standard`');
|
|
149
|
+
expect(getComputedStyle(holder).backgroundImage).to.include(thumbURL, 'computed style value added for background image');
|
|
150
|
+
expect(holder.style.getPropertyValue('--background-image')).to.equal(`url("${thumbURL}")`, 'image passed as custom css variable');
|
|
151
|
+
expect(el.ratio).to.equal('16 / 9', '`ratio` has default token value');
|
|
152
|
+
|
|
153
|
+
if (CSS.supports('aspect-ratio', '1 / 1')) {
|
|
154
|
+
expect(elementImage.style.getPropertyValue('--image-ratio')).to.equal('16 / 9', 'ratio passed as custom css variable');
|
|
155
|
+
expect(getComputedStyle(elementImage).aspectRatio).to.equal('16 / 9', 'computed style value added for aspect-ratio');
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('implements alt', async () => {
|
|
160
|
+
const el = await fixture(html`<${tag} src="${imageURL}" alt="alternative text for the image"></${tag}>`);
|
|
161
|
+
|
|
162
|
+
await awaitLoading(el);
|
|
163
|
+
await defaultChecks(el);
|
|
164
|
+
|
|
165
|
+
const shadowRoot = el.shadowRoot;
|
|
166
|
+
const elementImage = shadowRoot.querySelector('.image');
|
|
167
|
+
const img = elementImage.querySelector('img');
|
|
168
|
+
|
|
169
|
+
expect(elementImage).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
170
|
+
expect(el.type).to.equal('standard', '`type` property has default value `standard`');
|
|
171
|
+
expect(el.ratio).to.equal('16 / 9', '`ratio` has default token value');
|
|
172
|
+
expect(img.src).to.include(imageURL, 'has `src` value from el');
|
|
173
|
+
expect(img.alt).to.equal('alternative text for the image', 'alt has a value');
|
|
174
|
+
expect(Array.from(img.classList)).to.deep.equal(['blur-out', 'image-lazy']);
|
|
175
|
+
|
|
176
|
+
if (CSS.supports('aspect-ratio', '1 / 1')) {
|
|
177
|
+
expect(elementImage.style.getPropertyValue('--image-ratio')).to.equal('16 / 9', 'ratio passed as custom css variable');
|
|
178
|
+
expect(getComputedStyle(elementImage).aspectRatio).to.equal('16 / 9', 'computed style value added for aspect-ratio');
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('fallsback on ratio if not correct', async () => {
|
|
183
|
+
const el = await fixture(html`<${tag} src="${imageURL}" ratio="not-a-ratio"></${tag}>`);
|
|
184
|
+
|
|
185
|
+
await awaitLoading(el);
|
|
186
|
+
await defaultChecks(el);
|
|
187
|
+
|
|
188
|
+
const shadowRoot = el.shadowRoot;
|
|
189
|
+
const elementImage = shadowRoot.querySelector('.image');
|
|
190
|
+
const img = elementImage.querySelector('img');
|
|
191
|
+
|
|
192
|
+
expect(elementImage).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
193
|
+
expect(el.type).to.equal('standard', '`type` property has default value `standard`');
|
|
194
|
+
expect(el.ratio).to.equal('16 / 9', '`ratio` has default token value');
|
|
195
|
+
expect(img.src).to.include(imageURL, 'has `src` value from el');
|
|
196
|
+
expect(img.alt).to.equal('', 'alt has not value');
|
|
197
|
+
expect(Array.from(img.classList)).to.deep.equal(['blur-out', 'image-lazy']);
|
|
198
|
+
|
|
199
|
+
if (CSS.supports('aspect-ratio', '1 / 1')) {
|
|
200
|
+
expect(elementImage.style.getPropertyValue('--image-ratio')).to.equal('16 / 9', 'ratio passed as custom css variable');
|
|
201
|
+
expect(getComputedStyle(elementImage).aspectRatio).to.equal('16 / 9', 'computed style value added for aspect-ratio');
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it('image is eager', async () => {
|
|
206
|
+
const el = await fixture(html`<${tag} src="${imageURL}" loading="eager"></${tag}>`);
|
|
207
|
+
|
|
208
|
+
await awaitLoading(el);
|
|
209
|
+
await defaultChecks(el);
|
|
210
|
+
|
|
211
|
+
const shadowRoot = el.shadowRoot;
|
|
212
|
+
const elementImage = shadowRoot.querySelector('.image');
|
|
213
|
+
const img = elementImage.querySelector('img');
|
|
214
|
+
|
|
215
|
+
expect(elementImage).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
216
|
+
expect(el.type).to.equal('standard', '`type` property has default value `standard`');
|
|
217
|
+
expect(el.ratio).to.equal('16 / 9', '`ratio` has default token value');
|
|
218
|
+
expect(img.src).to.include(imageURL, 'has `src` value from el');
|
|
219
|
+
expect(img.alt).to.equal('', 'alt has not value');
|
|
220
|
+
expect(Array.from(img.classList)).to.deep.equal(['blur-out', 'image-lazy']);
|
|
221
|
+
|
|
222
|
+
if (CSS.supports('aspect-ratio', '1 / 1')) {
|
|
223
|
+
expect(elementImage.style.getPropertyValue('--image-ratio')).to.equal('16 / 9', 'ratio passed as custom css variable');
|
|
224
|
+
expect(getComputedStyle(elementImage).aspectRatio).to.equal('16 / 9', 'computed style value added for aspect-ratio');
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it('fallsback on image padding if aspect-ratio not available', async () => {
|
|
229
|
+
sinon.replace(
|
|
230
|
+
CSS,
|
|
231
|
+
'supports',
|
|
232
|
+
sinon.fake.returns(false)
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
const el = await fixture(html`<${tag} src="${imageURL}"></${tag}>`);
|
|
236
|
+
|
|
237
|
+
await awaitLoading(el);
|
|
238
|
+
await defaultChecks(el);
|
|
239
|
+
|
|
240
|
+
const shadowRoot = el.shadowRoot;
|
|
241
|
+
const elementImage = shadowRoot.querySelector('.image');
|
|
242
|
+
const img = elementImage.querySelector('img');
|
|
243
|
+
|
|
244
|
+
expect(elementImage).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
245
|
+
expect(el.type).to.equal('standard', '`type` property has default value `standard`');
|
|
246
|
+
expect(el.ratio).to.equal('16 / 9', '`ratio` has default token value');
|
|
247
|
+
expect(img.src).to.include(imageURL, 'has `src` value from el');
|
|
248
|
+
expect(img.alt).to.equal('', 'alt has not value');
|
|
249
|
+
expect(elementImage.style.getPropertyValue('--image-padding')).to.equal('56.25%', 'ratio percentage passed as custom css variable');
|
|
250
|
+
// expect(getComputedStyle(elementImage).paddingTop).to.equal('56.25%', 'computed style value added padding top');
|
|
251
|
+
// @TODO: work out how to fake @supports in CSS
|
|
252
|
+
expect(Array.from(img.classList)).to.deep.equal(['blur-out', 'image-lazy']);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it('image fails to load', async () => {
|
|
256
|
+
const consoleError = sinon.stub(console, 'error');
|
|
257
|
+
const el = await fixture(html`<${tag} src="this-is-not-an-image"></${tag}>`);
|
|
258
|
+
|
|
259
|
+
await awaitFailed();
|
|
260
|
+
await defaultChecks(el);
|
|
261
|
+
|
|
262
|
+
const shadowRoot = el.shadowRoot;
|
|
263
|
+
const elementImage = shadowRoot.querySelector('.image');
|
|
264
|
+
const img = elementImage.querySelector('img');
|
|
265
|
+
|
|
266
|
+
expect(elementImage).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
267
|
+
expect(img).to.be.null; // eslint-disable-line no-unused-expressions
|
|
268
|
+
expect(el.type).to.equal('standard', '`type` property has default value `standard`');
|
|
269
|
+
expect(el.ratio).to.equal('16 / 9', '`ratio` has default token value');
|
|
270
|
+
expect(consoleError.args[0]).to.deep.equal(['Image (this-is-not-an-image) failed to load']);
|
|
271
|
+
|
|
272
|
+
if (CSS.supports('aspect-ratio', '1 / 1')) {
|
|
273
|
+
expect(elementImage.style.getPropertyValue('--image-ratio')).to.equal('16 / 9', 'ratio passed as custom css variable');
|
|
274
|
+
expect(getComputedStyle(elementImage).aspectRatio).to.equal('16 / 9', 'computed style value added for aspect-ratio');
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
it('image fails to load for background', async () => {
|
|
279
|
+
const consoleError = sinon.stub(console, 'error');
|
|
280
|
+
const el = await fixture(html`<${tag} src="this-is-not-an-image"></${tag}>`);
|
|
281
|
+
|
|
282
|
+
await awaitFailed();
|
|
283
|
+
await defaultChecks(el);
|
|
284
|
+
|
|
285
|
+
expect(consoleError.args[0]).to.deep.equal(['Image (this-is-not-an-image) failed to load']);
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it('implements placeholder image for chrome', async () => {
|
|
289
|
+
if (window.chrome === true) {
|
|
290
|
+
const el = await fixture(html`<${tag} src="https://via.placeholder.com/35000" placeholder="${thumbURL}"></${tag}>`);
|
|
291
|
+
|
|
292
|
+
await nextFrame();
|
|
293
|
+
await defaultChecks(el);
|
|
294
|
+
|
|
295
|
+
const shadowRoot = el.shadowRoot;
|
|
296
|
+
const elementImage = shadowRoot.querySelector('.image');
|
|
297
|
+
const img = elementImage.querySelector('img');
|
|
298
|
+
|
|
299
|
+
expect(elementImage).to.not.be.null; // eslint-disable-line no-unused-expressions
|
|
300
|
+
expect(el.type).to.equal('standard', '`type` property has default value `standard`');
|
|
301
|
+
expect(el.ratio).to.equal('16 / 9', '`ratio` has default token value');
|
|
302
|
+
expect(img.src).to.equal(thumbURL, 'has `src` value from el');
|
|
303
|
+
expect(img.alt).to.equal('', 'alt has not value');
|
|
304
|
+
expect(img.loading).to.equal('lazy', 'loading has a value');
|
|
305
|
+
expect(Array.from(img.classList)).to.deep.equal(['image-lazy', 'blur']);
|
|
306
|
+
|
|
307
|
+
if (CSS.supports('aspect-ratio', '1 / 1')) {
|
|
308
|
+
expect(elementImage.style.getPropertyValue('--image-ratio')).to.equal('16 / 9', 'ratio passed as custom css variable');
|
|
309
|
+
expect(getComputedStyle(elementImage).aspectRatio).to.equal('16 / 9', 'computed style value added for aspect-ratio');
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
});
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
/* @web/test-runner snapshot v1 */
|
|
2
|
+
export const snapshots = {};
|
|
3
|
+
snapshots["Inputter standard default"] =
|
|
4
|
+
`<div
|
|
5
|
+
class="inputter"
|
|
6
|
+
style=""
|
|
7
|
+
>
|
|
8
|
+
<slot name="label">
|
|
9
|
+
</slot>
|
|
10
|
+
<div class="wrapper">
|
|
11
|
+
<slot>
|
|
12
|
+
</slot>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
`;
|
|
16
|
+
/* end snapshot Inputter standard default */
|
|
17
|
+
|
|
18
|
+
snapshots["Inputter helper text"] =
|
|
19
|
+
`<div
|
|
20
|
+
class="inputter"
|
|
21
|
+
style=""
|
|
22
|
+
>
|
|
23
|
+
<slot name="label">
|
|
24
|
+
</slot>
|
|
25
|
+
<div class="helper">
|
|
26
|
+
What is this?
|
|
27
|
+
</div>
|
|
28
|
+
<div class="wrapper">
|
|
29
|
+
<slot>
|
|
30
|
+
</slot>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
`;
|
|
34
|
+
/* end snapshot Inputter helper text */
|
|
35
|
+
|
|
36
|
+
snapshots["Inputter helper detail"] =
|
|
37
|
+
`<div
|
|
38
|
+
class="inputter"
|
|
39
|
+
style=""
|
|
40
|
+
>
|
|
41
|
+
<slot name="label">
|
|
42
|
+
</slot>
|
|
43
|
+
<inputter-detail>
|
|
44
|
+
<div slot="heading">
|
|
45
|
+
What is this?
|
|
46
|
+
</div>
|
|
47
|
+
<slot name="tip-details">
|
|
48
|
+
</slot>
|
|
49
|
+
</inputter-detail>
|
|
50
|
+
<div class="wrapper">
|
|
51
|
+
<slot>
|
|
52
|
+
</slot>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
`;
|
|
56
|
+
/* end snapshot Inputter helper detail */
|
|
57
|
+
|
|
58
|
+
snapshots["Inputter helper detail open"] =
|
|
59
|
+
`<div
|
|
60
|
+
class="inputter"
|
|
61
|
+
style=""
|
|
62
|
+
>
|
|
63
|
+
<slot name="label">
|
|
64
|
+
</slot>
|
|
65
|
+
<inputter-detail open="">
|
|
66
|
+
<div slot="heading">
|
|
67
|
+
What is this?
|
|
68
|
+
</div>
|
|
69
|
+
<slot name="tip-details">
|
|
70
|
+
</slot>
|
|
71
|
+
</inputter-detail>
|
|
72
|
+
<div class="wrapper">
|
|
73
|
+
<slot>
|
|
74
|
+
</slot>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
`;
|
|
78
|
+
/* end snapshot Inputter helper detail open */
|
|
79
|
+
|
|
80
|
+
snapshots["Inputter text mask text"] =
|
|
81
|
+
`<div
|
|
82
|
+
class="has-mask inputter"
|
|
83
|
+
style="--maxlength:4;"
|
|
84
|
+
>
|
|
85
|
+
<slot name="label">
|
|
86
|
+
</slot>
|
|
87
|
+
<div class="wrapper">
|
|
88
|
+
<slot>
|
|
89
|
+
</slot>
|
|
90
|
+
<div
|
|
91
|
+
aria-hidden="true"
|
|
92
|
+
class="input-mask"
|
|
93
|
+
>
|
|
94
|
+
0000
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
`;
|
|
99
|
+
/* end snapshot Inputter text mask text */
|
|
100
|
+
|
|
101
|
+
snapshots["Inputter text validation"] =
|
|
102
|
+
`<div
|
|
103
|
+
class="inputter"
|
|
104
|
+
style=""
|
|
105
|
+
>
|
|
106
|
+
<slot name="label">
|
|
107
|
+
</slot>
|
|
108
|
+
<div class="wrapper">
|
|
109
|
+
<slot>
|
|
110
|
+
</slot>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
`;
|
|
114
|
+
/* end snapshot Inputter text validation */
|
|
115
|
+
|
|
116
|
+
snapshots["Inputter radio standard radio"] =
|
|
117
|
+
`<div
|
|
118
|
+
class="inputter radio"
|
|
119
|
+
style=""
|
|
120
|
+
>
|
|
121
|
+
<span class="input-heading">
|
|
122
|
+
What is your heating source?
|
|
123
|
+
</span>
|
|
124
|
+
<div class="wrapper">
|
|
125
|
+
<slot>
|
|
126
|
+
</slot>
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
`;
|
|
130
|
+
/* end snapshot Inputter radio standard radio */
|
|
131
|
+
|
|
132
|
+
snapshots["Inputter standard default"] =
|
|
133
|
+
`<div
|
|
134
|
+
class="inputter"
|
|
135
|
+
style=""
|
|
136
|
+
>
|
|
137
|
+
<slot name="label">
|
|
138
|
+
</slot>
|
|
139
|
+
<div class="wrapper">
|
|
140
|
+
<slot>
|
|
141
|
+
</slot>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
`;
|
|
145
|
+
/* end snapshot Inputter standard default */
|
|
146
|
+
|
|
147
|
+
snapshots["Inputter helper text"] =
|
|
148
|
+
`<div
|
|
149
|
+
class="inputter"
|
|
150
|
+
style=""
|
|
151
|
+
>
|
|
152
|
+
<slot name="label">
|
|
153
|
+
</slot>
|
|
154
|
+
<div class="helper">
|
|
155
|
+
What is this?
|
|
156
|
+
</div>
|
|
157
|
+
<div class="wrapper">
|
|
158
|
+
<slot>
|
|
159
|
+
</slot>
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
`;
|
|
163
|
+
/* end snapshot Inputter helper text */
|
|
164
|
+
|
|
165
|
+
snapshots["Inputter helper detail"] =
|
|
166
|
+
`<div
|
|
167
|
+
class="inputter"
|
|
168
|
+
style=""
|
|
169
|
+
>
|
|
170
|
+
<slot name="label">
|
|
171
|
+
</slot>
|
|
172
|
+
<inputter-detail>
|
|
173
|
+
<div slot="heading">
|
|
174
|
+
What is this?
|
|
175
|
+
</div>
|
|
176
|
+
<slot name="tip-details">
|
|
177
|
+
</slot>
|
|
178
|
+
</inputter-detail>
|
|
179
|
+
<div class="wrapper">
|
|
180
|
+
<slot>
|
|
181
|
+
</slot>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
`;
|
|
185
|
+
/* end snapshot Inputter helper detail */
|
|
186
|
+
|
|
187
|
+
snapshots["Inputter helper detail open"] =
|
|
188
|
+
`<div
|
|
189
|
+
class="inputter"
|
|
190
|
+
style=""
|
|
191
|
+
>
|
|
192
|
+
<slot name="label">
|
|
193
|
+
</slot>
|
|
194
|
+
<inputter-detail open="">
|
|
195
|
+
<div slot="heading">
|
|
196
|
+
What is this?
|
|
197
|
+
</div>
|
|
198
|
+
<slot name="tip-details">
|
|
199
|
+
</slot>
|
|
200
|
+
</inputter-detail>
|
|
201
|
+
<div class="wrapper">
|
|
202
|
+
<slot>
|
|
203
|
+
</slot>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
`;
|
|
207
|
+
/* end snapshot Inputter helper detail open */
|
|
208
|
+
|
|
209
|
+
snapshots["Inputter select standard select"] =
|
|
210
|
+
`<div
|
|
211
|
+
class="inputter select"
|
|
212
|
+
style=""
|
|
213
|
+
>
|
|
214
|
+
<slot name="label">
|
|
215
|
+
</slot>
|
|
216
|
+
<div class="wrapper">
|
|
217
|
+
<slot>
|
|
218
|
+
</slot>
|
|
219
|
+
<inputter-icon name="chevron-circle-down">
|
|
220
|
+
</inputter-icon>
|
|
221
|
+
</div>
|
|
222
|
+
</div>
|
|
223
|
+
`;
|
|
224
|
+
/* end snapshot Inputter select standard select */
|
|
225
|
+
|
|
226
|
+
snapshots["Inputter search standard search"] =
|
|
227
|
+
`<div
|
|
228
|
+
class="inputter search"
|
|
229
|
+
style=""
|
|
230
|
+
>
|
|
231
|
+
<slot name="label">
|
|
232
|
+
</slot>
|
|
233
|
+
<div class="wrapper">
|
|
234
|
+
<slot>
|
|
235
|
+
</slot>
|
|
236
|
+
<inputter-icon name="search">
|
|
237
|
+
</inputter-icon>
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
`;
|
|
241
|
+
/* end snapshot Inputter search standard search */
|
|
242
|
+
|
|
243
|
+
snapshots["Inputter date standard date"] =
|
|
244
|
+
`<div
|
|
245
|
+
class="date inputter"
|
|
246
|
+
style=""
|
|
247
|
+
>
|
|
248
|
+
<slot name="label">
|
|
249
|
+
</slot>
|
|
250
|
+
<div class="wrapper">
|
|
251
|
+
<slot>
|
|
252
|
+
</slot>
|
|
253
|
+
<inputter-icon name="calendar">
|
|
254
|
+
</inputter-icon>
|
|
255
|
+
</div>
|
|
256
|
+
</div>
|
|
257
|
+
`;
|
|
258
|
+
/* end snapshot Inputter date standard date */
|
|
259
|
+
|
|
260
|
+
snapshots["Inputter text disabled"] =
|
|
261
|
+
`<div
|
|
262
|
+
class="has-disabled inputter"
|
|
263
|
+
style=""
|
|
264
|
+
>
|
|
265
|
+
<slot name="label">
|
|
266
|
+
</slot>
|
|
267
|
+
<div class="wrapper">
|
|
268
|
+
<slot>
|
|
269
|
+
</slot>
|
|
270
|
+
</div>
|
|
271
|
+
</div>
|
|
272
|
+
`;
|
|
273
|
+
/* end snapshot Inputter text disabled */
|
|
274
|
+
|
|
275
|
+
snapshots["Inputter text mask & validation"] =
|
|
276
|
+
`<div
|
|
277
|
+
class="has-mask inputter"
|
|
278
|
+
style="--maxlength:4;"
|
|
279
|
+
>
|
|
280
|
+
<slot name="label">
|
|
281
|
+
</slot>
|
|
282
|
+
<div class="wrapper">
|
|
283
|
+
<slot>
|
|
284
|
+
</slot>
|
|
285
|
+
<div
|
|
286
|
+
aria-hidden="true"
|
|
287
|
+
class="input-mask"
|
|
288
|
+
>
|
|
289
|
+
0000
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
`;
|
|
294
|
+
/* end snapshot Inputter text mask & validation */
|
|
295
|
+
|
|
296
|
+
snapshots["Inputter radio radio mask"] =
|
|
297
|
+
`<div
|
|
298
|
+
class="has-mask inputter radio"
|
|
299
|
+
style="--maxlength:3;"
|
|
300
|
+
>
|
|
301
|
+
<span class="input-heading">
|
|
302
|
+
What is your heating source?
|
|
303
|
+
</span>
|
|
304
|
+
<div class="wrapper">
|
|
305
|
+
<slot>
|
|
306
|
+
</slot>
|
|
307
|
+
</div>
|
|
308
|
+
</div>
|
|
309
|
+
`;
|
|
310
|
+
/* end snapshot Inputter radio radio mask */
|
|
311
|
+
|
|
312
|
+
snapshots["Inputter radio radio mask validation"] =
|
|
313
|
+
`<div
|
|
314
|
+
class="has-mask inputter radio"
|
|
315
|
+
style="--maxlength:3;"
|
|
316
|
+
>
|
|
317
|
+
<span class="input-heading">
|
|
318
|
+
What is your heating source?
|
|
319
|
+
</span>
|
|
320
|
+
<div class="wrapper">
|
|
321
|
+
<slot>
|
|
322
|
+
</slot>
|
|
323
|
+
</div>
|
|
324
|
+
</div>
|
|
325
|
+
`;
|
|
326
|
+
/* end snapshot Inputter radio radio mask validation */
|
|
327
|
+
|
|
328
|
+
snapshots["Inputter text validation on input"] =
|
|
329
|
+
`<div
|
|
330
|
+
class="inputter"
|
|
331
|
+
style=""
|
|
332
|
+
>
|
|
333
|
+
<slot name="label">
|
|
334
|
+
</slot>
|
|
335
|
+
<div class="wrapper">
|
|
336
|
+
<slot>
|
|
337
|
+
</slot>
|
|
338
|
+
</div>
|
|
339
|
+
</div>
|
|
340
|
+
`;
|
|
341
|
+
/* end snapshot Inputter text validation on input */
|
|
342
|
+
|
|
343
|
+
snapshots["Inputter text validation on change"] =
|
|
344
|
+
`<div
|
|
345
|
+
class="inputter"
|
|
346
|
+
style=""
|
|
347
|
+
>
|
|
348
|
+
<slot name="label">
|
|
349
|
+
</slot>
|
|
350
|
+
<div class="wrapper">
|
|
351
|
+
<slot>
|
|
352
|
+
</slot>
|
|
353
|
+
</div>
|
|
354
|
+
</div>
|
|
355
|
+
`;
|
|
356
|
+
/* end snapshot Inputter text validation on change */
|
|
357
|
+
|