@spectrum-web-components/base 1.1.0-beta.9 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/version.js +1 -1
- package/test/sizedMixin.test.js +60 -0
- package/test/sizedMixin.test.js.map +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/base",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"sideEffects": [
|
|
121
121
|
"./**/*.dev.js"
|
|
122
122
|
],
|
|
123
|
-
"gitHead": "
|
|
123
|
+
"gitHead": "44870aa95001c1b995456d994ae31bbe7277fac9"
|
|
124
124
|
}
|
package/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '1.
|
|
2
|
+
export const version = '1.0.3';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import {
|
|
3
|
+
SizedMixin,
|
|
4
|
+
SpectrumElement
|
|
5
|
+
} from "../src/index.js";
|
|
6
|
+
import { html } from "@open-wc/testing";
|
|
7
|
+
import { elementUpdated, expect, fixture } from "@open-wc/testing";
|
|
8
|
+
export class FancySizedComponent extends SizedMixin(SpectrumElement, {
|
|
9
|
+
defaultSize: "m",
|
|
10
|
+
validSizes: ["xs", "s", "m", "l", "xl"]
|
|
11
|
+
}) {
|
|
12
|
+
render() {
|
|
13
|
+
return html`
|
|
14
|
+
I an wearing size ${this.size}
|
|
15
|
+
`;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
customElements.define("fancy-sized-component", FancySizedComponent);
|
|
19
|
+
describe("sizedMixin", () => {
|
|
20
|
+
it("allows any given size in the validSizes array", async () => {
|
|
21
|
+
const validSizesChecks = ["xs", "s", "m", "l", "xl"].map(async (size) => {
|
|
22
|
+
var _a;
|
|
23
|
+
const el = await fixture(html`
|
|
24
|
+
<fancy-sized-component></fancy-sized-component>
|
|
25
|
+
`);
|
|
26
|
+
await elementUpdated(el);
|
|
27
|
+
el.size = size;
|
|
28
|
+
await elementUpdated(el);
|
|
29
|
+
expect((_a = el.shadowRoot) == null ? void 0 : _a.textContent).to.include(
|
|
30
|
+
`I an wearing size ${size}`
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
await Promise.all(validSizesChecks);
|
|
34
|
+
});
|
|
35
|
+
it("fallbacks to default size if the provided size is invalid", async () => {
|
|
36
|
+
var _a;
|
|
37
|
+
const el = await fixture(html`
|
|
38
|
+
<fancy-sized-component size="xxl"></fancy-sized-component>
|
|
39
|
+
`);
|
|
40
|
+
await elementUpdated(el);
|
|
41
|
+
expect((_a = el.shadowRoot) == null ? void 0 : _a.textContent).to.include("I an wearing size m");
|
|
42
|
+
});
|
|
43
|
+
it("fallbacks to default size if no size is provided", async () => {
|
|
44
|
+
var _a;
|
|
45
|
+
const el = await fixture(html`
|
|
46
|
+
<fancy-sized-component></fancy-sized-component>
|
|
47
|
+
`);
|
|
48
|
+
await elementUpdated(el);
|
|
49
|
+
expect((_a = el.shadowRoot) == null ? void 0 : _a.textContent).to.include("I an wearing size m");
|
|
50
|
+
});
|
|
51
|
+
it("applies the given size if it is a valid one", async () => {
|
|
52
|
+
var _a;
|
|
53
|
+
const el = await fixture(html`
|
|
54
|
+
<fancy-sized-component size="l"></fancy-sized-component>
|
|
55
|
+
`);
|
|
56
|
+
await elementUpdated(el);
|
|
57
|
+
expect((_a = el.shadowRoot) == null ? void 0 : _a.textContent).to.include("I an wearing size l");
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=sizedMixin.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sizedMixin.test.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2025 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n ElementSize,\n SizedMixin,\n SpectrumElement,\n TemplateResult,\n} from '../src/index.js';\nimport { html } from '@open-wc/testing';\nimport { elementUpdated, expect, fixture } from '@open-wc/testing';\n\nexport class FancySizedComponent extends SizedMixin(SpectrumElement, {\n defaultSize: 'm',\n validSizes: ['xs', 's', 'm', 'l', 'xl'],\n}) {\n public override render(): TemplateResult {\n return html`\n I an wearing size ${this.size}\n `;\n }\n}\n\ncustomElements.define('fancy-sized-component', FancySizedComponent);\n\ndescribe('sizedMixin', () => {\n it('allows any given size in the validSizes array', async () => {\n const validSizesChecks = (\n ['xs', 's', 'm', 'l', 'xl'] as ElementSize[]\n ).map(async (size) => {\n const el = await fixture<FancySizedComponent>(html`\n <fancy-sized-component></fancy-sized-component>\n `);\n await elementUpdated(el);\n\n el.size = size;\n await elementUpdated(el);\n expect(el.shadowRoot?.textContent).to.include(\n `I an wearing size ${size}`\n );\n });\n\n await Promise.all(validSizesChecks);\n });\n\n it('fallbacks to default size if the provided size is invalid', async () => {\n const el = await fixture<FancySizedComponent>(html`\n <fancy-sized-component size=\"xxl\"></fancy-sized-component>\n `);\n await elementUpdated(el);\n\n // Fallback is 'm', as defined by `defaultSize`.\n expect(el.shadowRoot?.textContent).to.include('I an wearing size m');\n });\n\n it('fallbacks to default size if no size is provided', async () => {\n const el = await fixture<FancySizedComponent>(html`\n <fancy-sized-component></fancy-sized-component>\n `);\n await elementUpdated(el);\n\n // Default is 'm', as defined by `defaultSize`.\n expect(el.shadowRoot?.textContent).to.include('I an wearing size m');\n });\n\n it('applies the given size if it is a valid one', async () => {\n const el = await fixture<FancySizedComponent>(html`\n <fancy-sized-component size=\"l\"></fancy-sized-component>\n `);\n await elementUpdated(el);\n\n expect(el.shadowRoot?.textContent).to.include('I an wearing size l');\n });\n});\n"],
|
|
5
|
+
"mappings": ";AAYA;AAAA,EAEI;AAAA,EACA;AAAA,OAEG;AACP,SAAS,YAAY;AACrB,SAAS,gBAAgB,QAAQ,eAAe;AAEzC,aAAM,4BAA4B,WAAW,iBAAiB;AAAA,EACjE,aAAa;AAAA,EACb,YAAY,CAAC,MAAM,KAAK,KAAK,KAAK,IAAI;AAC1C,CAAC,EAAE;AAAA,EACiB,SAAyB;AACrC,WAAO;AAAA,gCACiB,KAAK,IAAI;AAAA;AAAA,EAErC;AACJ;AAEA,eAAe,OAAO,yBAAyB,mBAAmB;AAElE,SAAS,cAAc,MAAM;AACzB,KAAG,iDAAiD,YAAY;AAC5D,UAAM,mBACF,CAAC,MAAM,KAAK,KAAK,KAAK,IAAI,EAC5B,IAAI,OAAO,SAAS;AAtC9B;AAuCY,YAAM,KAAK,MAAM,QAA6B;AAAA;AAAA,aAE7C;AACD,YAAM,eAAe,EAAE;AAEvB,SAAG,OAAO;AACV,YAAM,eAAe,EAAE;AACvB,cAAO,QAAG,eAAH,mBAAe,WAAW,EAAE,GAAG;AAAA,QAClC,qBAAqB,IAAI;AAAA,MAC7B;AAAA,IACJ,CAAC;AAED,UAAM,QAAQ,IAAI,gBAAgB;AAAA,EACtC,CAAC;AAED,KAAG,6DAA6D,YAAY;AAtDhF;AAuDQ,UAAM,KAAK,MAAM,QAA6B;AAAA;AAAA,SAE7C;AACD,UAAM,eAAe,EAAE;AAGvB,YAAO,QAAG,eAAH,mBAAe,WAAW,EAAE,GAAG,QAAQ,qBAAqB;AAAA,EACvE,CAAC;AAED,KAAG,oDAAoD,YAAY;AAhEvE;AAiEQ,UAAM,KAAK,MAAM,QAA6B;AAAA;AAAA,SAE7C;AACD,UAAM,eAAe,EAAE;AAGvB,YAAO,QAAG,eAAH,mBAAe,WAAW,EAAE,GAAG,QAAQ,qBAAqB;AAAA,EACvE,CAAC;AAED,KAAG,+CAA+C,YAAY;AA1ElE;AA2EQ,UAAM,KAAK,MAAM,QAA6B;AAAA;AAAA,SAE7C;AACD,UAAM,eAAe,EAAE;AAEvB,YAAO,QAAG,eAAH,mBAAe,WAAW,EAAE,GAAG,QAAQ,qBAAqB;AAAA,EACvE,CAAC;AACL,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|