@spectrum-web-components/theme 0.46.0 → 0.47.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/theme",
3
- "version": "0.46.0",
3
+ "version": "0.47.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -233,8 +233,8 @@
233
233
  "lit-html"
234
234
  ],
235
235
  "dependencies": {
236
- "@spectrum-web-components/base": "^0.46.0",
237
- "@spectrum-web-components/styles": "^0.46.0"
236
+ "@spectrum-web-components/base": "^0.47.1",
237
+ "@spectrum-web-components/styles": "^0.47.1"
238
238
  },
239
239
  "types": "./src/index.d.ts",
240
240
  "customElements": "custom-elements.json",
@@ -261,5 +261,5 @@
261
261
  "./src/spectrum-two/themes.js",
262
262
  "./src/spectrum-two/themes-*.js"
263
263
  ],
264
- "gitHead": "ab84b447210de593649b086a1605abf1be1d64f2"
264
+ "gitHead": "151a3e21c39150dbc3f3a884b660be0bd352bda1"
265
265
  }
@@ -6,41 +6,33 @@ import { elementUpdated, expect, fixture, html } from "@open-wc/testing";
6
6
  import { css } from "@spectrum-web-components/base";
7
7
  describe("Systems", () => {
8
8
  it("loads - light", async () => {
9
- const el = await fixture(
10
- html`
11
- <sp-theme system="spectrum" color="light"></sp-theme>
12
- `
13
- );
9
+ const el = await fixture(html`
10
+ <sp-theme system="spectrum" color="light"></sp-theme>
11
+ `);
14
12
  await elementUpdated(el);
15
13
  expect(el).to.exist;
16
14
  expect(el).shadowDom.to.exist;
17
15
  });
18
16
  it("loads - dark", async () => {
19
- const el = await fixture(
20
- html`
21
- <sp-theme color="dark"></sp-theme>
22
- `
23
- );
17
+ const el = await fixture(html`
18
+ <sp-theme color="dark"></sp-theme>
19
+ `);
24
20
  await elementUpdated(el);
25
21
  expect(el).to.exist;
26
22
  expect(el).shadowDom.to.exist;
27
23
  });
28
24
  it("loads - unkown", async () => {
29
- const el = await fixture(
30
- html`
31
- <sp-theme color="unknown" scale="unknown"></sp-theme>
32
- `
33
- );
25
+ const el = await fixture(html`
26
+ <sp-theme color="unknown" scale="unknown"></sp-theme>
27
+ `);
34
28
  await elementUpdated(el);
35
29
  expect(el).to.exist;
36
30
  expect(el).shadowDom.to.exist;
37
31
  });
38
32
  it("adds an instance only once", async () => {
39
- const el = await fixture(
40
- html`
41
- <sp-theme system="express"></sp-theme>
42
- `
43
- );
33
+ const el = await fixture(html`
34
+ <sp-theme system="express"></sp-theme>
35
+ `);
44
36
  await elementUpdated(el);
45
37
  const testableTheme = Theme;
46
38
  expect(testableTheme.instances.has(el), "first").to.be.true;
@@ -55,11 +47,9 @@ describe("Systems", () => {
55
47
  });
56
48
  describe("Lightest", () => {
57
49
  it("loads", async () => {
58
- const el = await fixture(
59
- html`
60
- <sp-theme color="lightest"></sp-theme>
61
- `
62
- );
50
+ const el = await fixture(html`
51
+ <sp-theme color="lightest"></sp-theme>
52
+ `);
63
53
  await elementUpdated(el);
64
54
  expect(el).to.exist;
65
55
  expect(el).shadowDom.to.exist;
@@ -67,11 +57,9 @@ describe("Lightest", () => {
67
57
  });
68
58
  describe("Medium", () => {
69
59
  it("loads", async () => {
70
- const el = await fixture(
71
- html`
72
- <sp-theme scale="medium"></sp-theme>
73
- `
74
- );
60
+ const el = await fixture(html`
61
+ <sp-theme scale="medium"></sp-theme>
62
+ `);
75
63
  await elementUpdated(el);
76
64
  expect(el).to.exist;
77
65
  expect(el).shadowDom.to.exist;
@@ -79,18 +67,16 @@ describe("Medium", () => {
79
67
  });
80
68
  describe("App styles", () => {
81
69
  it("applies app fragments", async () => {
82
- const el = await fixture(
83
- html`
84
- <sp-theme color="light">
85
- <style>
86
- div {
87
- padding: var(--app-padding);
88
- }
89
- </style>
90
- <div></div>
91
- </sp-theme>
92
- `
93
- );
70
+ const el = await fixture(html`
71
+ <sp-theme color="light">
72
+ <style>
73
+ div {
74
+ padding: var(--app-padding);
75
+ }
76
+ </style>
77
+ <div></div>
78
+ </sp-theme>
79
+ `);
94
80
  const div = el.querySelector("div");
95
81
  await elementUpdated(el);
96
82
  const preStylesDiv = getComputedStyle(div);
@@ -112,11 +98,9 @@ describe("App styles", () => {
112
98
  });
113
99
  describe("Setting attributes", () => {
114
100
  it("loads", async () => {
115
- const el = await fixture(
116
- html`
117
- <sp-theme color="light"></sp-theme>
118
- `
119
- );
101
+ const el = await fixture(html`
102
+ <sp-theme color="light"></sp-theme>
103
+ `);
120
104
  await elementUpdated(el);
121
105
  expect(el).to.not.be.undefined;
122
106
  expect(el.hasAttribute("scale")).to.be.false;
@@ -161,11 +145,9 @@ describe("Setting attributes", () => {
161
145
  }
162
146
  });
163
147
  it("prefers system over theme", async () => {
164
- const el = await fixture(
165
- html`
166
- <sp-theme system="express"></sp-theme>
167
- `
168
- );
148
+ const el = await fixture(html`
149
+ <sp-theme system="express"></sp-theme>
150
+ `);
169
151
  await elementUpdated(el);
170
152
  expect(el.system).to.equal("express");
171
153
  el.setAttribute("theme", "classic");
@@ -176,11 +158,9 @@ describe("Setting attributes", () => {
176
158
  });
177
159
  describe("Themes", () => {
178
160
  it("updates system value even if only theme is added to sp-theme", async () => {
179
- const el = await fixture(
180
- html`
181
- <sp-theme theme="express"></sp-theme>
182
- `
183
- );
161
+ const el = await fixture(html`
162
+ <sp-theme theme="express"></sp-theme>
163
+ `);
184
164
  await elementUpdated(el);
185
165
  expect(el.theme).to.equal("express");
186
166
  el.setAttribute("theme", "spectrum");
@@ -189,11 +169,9 @@ describe("Themes", () => {
189
169
  expect(el.system).to.equal("spectrum");
190
170
  });
191
171
  it("updates system and theme value iif both are added to sp-theme", async () => {
192
- const el = await fixture(
193
- html`
194
- <sp-theme system="spectrum" theme="spectrum"></sp-theme>
195
- `
196
- );
172
+ const el = await fixture(html`
173
+ <sp-theme system="spectrum" theme="spectrum"></sp-theme>
174
+ `);
197
175
  await elementUpdated(el);
198
176
  expect(el.theme).to.equal("spectrum");
199
177
  expect(el.system).to.equal("spectrum");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["themes.test.ts"],
4
- "sourcesContent": ["/*\nCopyright 2020 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 '@spectrum-web-components/theme/sp-theme.js';\nimport '@spectrum-web-components/theme/src/themes.js';\nimport { Theme, ThemeFragmentMap } from '@spectrum-web-components/theme';\nimport { elementUpdated, expect, fixture, html } from '@open-wc/testing';\nimport { css } from '@spectrum-web-components/base';\n\ntype TestableThemeConstructor = {\n instances: Set<Theme>;\n themeFragmentsByKind: ThemeFragmentMap;\n};\n\ndescribe('Systems', () => {\n it('loads - light', async () => {\n const el = await fixture<Theme>(\n html`\n <sp-theme system=\"spectrum\" color=\"light\"></sp-theme>\n `\n );\n\n await elementUpdated(el);\n\n expect(el).to.exist;\n expect(el).shadowDom.to.exist;\n });\n it('loads - dark', async () => {\n const el = await fixture<Theme>(\n html`\n <sp-theme color=\"dark\"></sp-theme>\n `\n );\n\n await elementUpdated(el);\n\n expect(el).to.exist;\n expect(el).shadowDom.to.exist;\n });\n it('loads - unkown', async () => {\n const el = await fixture<Theme>(\n html`\n <sp-theme color=\"unknown\" scale=\"unknown\"></sp-theme>\n `\n );\n\n await elementUpdated(el);\n\n expect(el).to.exist;\n expect(el).shadowDom.to.exist;\n });\n it('adds an instance only once', async () => {\n const el = await fixture<Theme>(\n html`\n <sp-theme system=\"express\"></sp-theme>\n `\n );\n\n await elementUpdated(el);\n const testableTheme = Theme as unknown as TestableThemeConstructor;\n expect(testableTheme.instances.has(el), 'first').to.be.true;\n expect(testableTheme.instances.size).to.equal(1);\n\n el.remove();\n expect(testableTheme.instances.has(el), 'second').to.be.false;\n expect(testableTheme.instances.size).to.equal(0);\n\n document.body.append(el);\n expect(testableTheme.instances.has(el), 'third').to.be.true;\n expect(testableTheme.instances.size).to.equal(1);\n });\n});\n\ndescribe('Lightest', () => {\n it('loads', async () => {\n const el = await fixture<Theme>(\n html`\n <sp-theme color=\"lightest\"></sp-theme>\n `\n );\n\n await elementUpdated(el);\n\n expect(el).to.exist;\n expect(el).shadowDom.to.exist;\n });\n});\n\ndescribe('Medium', () => {\n it('loads', async () => {\n const el = await fixture<Theme>(\n html`\n <sp-theme scale=\"medium\"></sp-theme>\n `\n );\n\n await elementUpdated(el);\n\n expect(el).to.exist;\n expect(el).shadowDom.to.exist;\n });\n});\n\ndescribe('App styles', () => {\n it('applies app fragments', async () => {\n const el = await fixture<Theme>(\n html`\n <sp-theme color=\"light\">\n <style>\n div {\n padding: var(--app-padding);\n }\n </style>\n <div></div>\n </sp-theme>\n `\n );\n const div = el.querySelector('div') as HTMLDivElement;\n\n await elementUpdated(el);\n\n const preStylesDiv = getComputedStyle(div);\n expect(preStylesDiv.paddingBlockStart).to.equal('0px');\n\n Theme.registerThemeFragment(\n 'app',\n 'app',\n css`\n :host {\n --app-padding: 10px;\n }\n `\n );\n await elementUpdated(el);\n\n const postStylesDiv = getComputedStyle(div);\n expect(postStylesDiv.paddingBlockStart).to.equal('10px');\n\n (\n Theme as unknown as TestableThemeConstructor\n ).themeFragmentsByKind.delete('app');\n });\n});\n\ndescribe('Setting attributes', () => {\n it('loads', async () => {\n const el = await fixture<Theme>(\n html`\n <sp-theme color=\"light\"></sp-theme>\n `\n );\n\n await elementUpdated(el);\n\n expect(el).to.not.be.undefined;\n expect(el.hasAttribute('scale')).to.be.false;\n\n if (el.shadowRoot.adoptedStyleSheets) {\n expect(el.shadowRoot.adoptedStyleSheets.length).to.equal(2);\n } else {\n expect(\n [...el.shadowRoot.querySelectorAll('style')].length\n ).to.equal(2);\n }\n\n await elementUpdated(el);\n\n // Invalid initial value falls back to default\n el.setAttribute('scale', 'fish');\n expect(el.getAttribute('scale')).to.equal('medium');\n\n if (el.shadowRoot.adoptedStyleSheets) {\n expect(el.shadowRoot.adoptedStyleSheets.length).to.equal(2);\n } else {\n expect(\n [...el.shadowRoot.querySelectorAll('style')].length\n ).to.equal(2);\n }\n\n el.color = 'dark';\n el.scale = 'medium';\n\n await elementUpdated(el);\n expect(el.getAttribute('color')).to.equal('dark');\n expect(el.getAttribute('scale')).to.equal('medium');\n\n if (el.shadowRoot.adoptedStyleSheets) {\n expect(el.shadowRoot.adoptedStyleSheets.length, 'all').to.equal(3);\n } else {\n expect(\n [...el.shadowRoot.querySelectorAll('style')].length\n ).to.equal(3);\n }\n\n // Invalid second + value fallsback to previous\n el.setAttribute('color', 'fish');\n\n await elementUpdated(el);\n expect(el.getAttribute('color')).to.equal('dark');\n\n if (el.shadowRoot.adoptedStyleSheets) {\n expect(el.shadowRoot.adoptedStyleSheets.length, 'last').to.equal(3);\n } else {\n expect(\n [...el.shadowRoot.querySelectorAll('style')].length\n ).to.equal(3);\n }\n });\n\n it('prefers system over theme', async () => {\n const el = await fixture<Theme>(\n html`\n <sp-theme system=\"express\"></sp-theme>\n `\n );\n\n await elementUpdated(el);\n\n expect(el.system).to.equal('express');\n\n el.setAttribute('theme', 'classic');\n await elementUpdated(el);\n\n expect(el.system).to.equal('express');\n expect(el.theme).to.equal('express');\n });\n});\n\ndescribe('Themes', () => {\n it('updates system value even if only theme is added to sp-theme', async () => {\n const el = await fixture<Theme>(\n html`\n <sp-theme theme=\"express\"></sp-theme>\n `\n );\n\n await elementUpdated(el);\n\n expect(el.theme).to.equal('express');\n\n el.setAttribute('theme', 'spectrum');\n await elementUpdated(el);\n\n expect(el.theme).to.equal('spectrum');\n expect(el.system).to.equal('spectrum');\n });\n it('updates system and theme value iif both are added to sp-theme', async () => {\n const el = await fixture<Theme>(\n html`\n <sp-theme system=\"spectrum\" theme=\"spectrum\"></sp-theme>\n `\n );\n\n await elementUpdated(el);\n\n expect(el.theme).to.equal('spectrum');\n expect(el.system).to.equal('spectrum');\n\n el.setAttribute('theme', 'express');\n await elementUpdated(el);\n expect(el.theme).to.equal('express');\n expect(el.system).to.equal('express');\n });\n});\n"],
5
- "mappings": ";AAYA,OAAO;AACP,OAAO;AACP,SAAS,aAA+B;AACxC,SAAS,gBAAgB,QAAQ,SAAS,YAAY;AACtD,SAAS,WAAW;AAOpB,SAAS,WAAW,MAAM;AACtB,KAAG,iBAAiB,YAAY;AAC5B,UAAM,KAAK,MAAM;AAAA,MACb;AAAA;AAAA;AAAA,IAGJ;AAEA,UAAM,eAAe,EAAE;AAEvB,WAAO,EAAE,EAAE,GAAG;AACd,WAAO,EAAE,EAAE,UAAU,GAAG;AAAA,EAC5B,CAAC;AACD,KAAG,gBAAgB,YAAY;AAC3B,UAAM,KAAK,MAAM;AAAA,MACb;AAAA;AAAA;AAAA,IAGJ;AAEA,UAAM,eAAe,EAAE;AAEvB,WAAO,EAAE,EAAE,GAAG;AACd,WAAO,EAAE,EAAE,UAAU,GAAG;AAAA,EAC5B,CAAC;AACD,KAAG,kBAAkB,YAAY;AAC7B,UAAM,KAAK,MAAM;AAAA,MACb;AAAA;AAAA;AAAA,IAGJ;AAEA,UAAM,eAAe,EAAE;AAEvB,WAAO,EAAE,EAAE,GAAG;AACd,WAAO,EAAE,EAAE,UAAU,GAAG;AAAA,EAC5B,CAAC;AACD,KAAG,8BAA8B,YAAY;AACzC,UAAM,KAAK,MAAM;AAAA,MACb;AAAA;AAAA;AAAA,IAGJ;AAEA,UAAM,eAAe,EAAE;AACvB,UAAM,gBAAgB;AACtB,WAAO,cAAc,UAAU,IAAI,EAAE,GAAG,OAAO,EAAE,GAAG,GAAG;AACvD,WAAO,cAAc,UAAU,IAAI,EAAE,GAAG,MAAM,CAAC;AAE/C,OAAG,OAAO;AACV,WAAO,cAAc,UAAU,IAAI,EAAE,GAAG,QAAQ,EAAE,G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,UAAU;AACpC,WAAO,GAAG,MAAM,EAAE,GAAG,MAAM,UAAU;AAErC,OAAG,aAAa,SAAS,SAAS;AAClC,UAAM,eAAe,EAAE;AACvB,WAAO,GAAG,KAAK,EAAE,GAAG,MAAM,SAAS;AACnC,WAAO,GAAG,MAAM,EAAE,GAAG,MAAM,SAAS;AAAA,EACxC,CAAC;AACL,CAAC;",
4
+ "sourcesContent": ["/*\nCopyright 2020 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 '@spectrum-web-components/theme/sp-theme.js';\nimport '@spectrum-web-components/theme/src/themes.js';\nimport { Theme, ThemeFragmentMap } from '@spectrum-web-components/theme';\nimport { elementUpdated, expect, fixture, html } from '@open-wc/testing';\nimport { css } from '@spectrum-web-components/base';\n\ntype TestableThemeConstructor = {\n instances: Set<Theme>;\n themeFragmentsByKind: ThemeFragmentMap;\n};\n\ndescribe('Systems', () => {\n it('loads - light', async () => {\n const el = await fixture<Theme>(html`\n <sp-theme system=\"spectrum\" color=\"light\"></sp-theme>\n `);\n\n await elementUpdated(el);\n\n expect(el).to.exist;\n expect(el).shadowDom.to.exist;\n });\n it('loads - dark', async () => {\n const el = await fixture<Theme>(html`\n <sp-theme color=\"dark\"></sp-theme>\n `);\n\n await elementUpdated(el);\n\n expect(el).to.exist;\n expect(el).shadowDom.to.exist;\n });\n it('loads - unkown', async () => {\n const el = await fixture<Theme>(html`\n <sp-theme color=\"unknown\" scale=\"unknown\"></sp-theme>\n `);\n\n await elementUpdated(el);\n\n expect(el).to.exist;\n expect(el).shadowDom.to.exist;\n });\n it('adds an instance only once', async () => {\n const el = await fixture<Theme>(html`\n <sp-theme system=\"express\"></sp-theme>\n `);\n\n await elementUpdated(el);\n const testableTheme = Theme as unknown as TestableThemeConstructor;\n expect(testableTheme.instances.has(el), 'first').to.be.true;\n expect(testableTheme.instances.size).to.equal(1);\n\n el.remove();\n expect(testableTheme.instances.has(el), 'second').to.be.false;\n expect(testableTheme.instances.size).to.equal(0);\n\n document.body.append(el);\n expect(testableTheme.instances.has(el), 'third').to.be.true;\n expect(testableTheme.instances.size).to.equal(1);\n });\n});\n\ndescribe('Lightest', () => {\n it('loads', async () => {\n const el = await fixture<Theme>(html`\n <sp-theme color=\"lightest\"></sp-theme>\n `);\n\n await elementUpdated(el);\n\n expect(el).to.exist;\n expect(el).shadowDom.to.exist;\n });\n});\n\ndescribe('Medium', () => {\n it('loads', async () => {\n const el = await fixture<Theme>(html`\n <sp-theme scale=\"medium\"></sp-theme>\n `);\n\n await elementUpdated(el);\n\n expect(el).to.exist;\n expect(el).shadowDom.to.exist;\n });\n});\n\ndescribe('App styles', () => {\n it('applies app fragments', async () => {\n const el = await fixture<Theme>(html`\n <sp-theme color=\"light\">\n <style>\n div {\n padding: var(--app-padding);\n }\n </style>\n <div></div>\n </sp-theme>\n `);\n const div = el.querySelector('div') as HTMLDivElement;\n\n await elementUpdated(el);\n\n const preStylesDiv = getComputedStyle(div);\n expect(preStylesDiv.paddingBlockStart).to.equal('0px');\n\n Theme.registerThemeFragment(\n 'app',\n 'app',\n css`\n :host {\n --app-padding: 10px;\n }\n `\n );\n await elementUpdated(el);\n\n const postStylesDiv = getComputedStyle(div);\n expect(postStylesDiv.paddingBlockStart).to.equal('10px');\n\n (\n Theme as unknown as TestableThemeConstructor\n ).themeFragmentsByKind.delete('app');\n });\n});\n\ndescribe('Setting attributes', () => {\n it('loads', async () => {\n const el = await fixture<Theme>(html`\n <sp-theme color=\"light\"></sp-theme>\n `);\n\n await elementUpdated(el);\n\n expect(el).to.not.be.undefined;\n expect(el.hasAttribute('scale')).to.be.false;\n\n if (el.shadowRoot.adoptedStyleSheets) {\n expect(el.shadowRoot.adoptedStyleSheets.length).to.equal(2);\n } else {\n expect(\n [...el.shadowRoot.querySelectorAll('style')].length\n ).to.equal(2);\n }\n\n await elementUpdated(el);\n\n // Invalid initial value falls back to default\n el.setAttribute('scale', 'fish');\n expect(el.getAttribute('scale')).to.equal('medium');\n\n if (el.shadowRoot.adoptedStyleSheets) {\n expect(el.shadowRoot.adoptedStyleSheets.length).to.equal(2);\n } else {\n expect(\n [...el.shadowRoot.querySelectorAll('style')].length\n ).to.equal(2);\n }\n\n el.color = 'dark';\n el.scale = 'medium';\n\n await elementUpdated(el);\n expect(el.getAttribute('color')).to.equal('dark');\n expect(el.getAttribute('scale')).to.equal('medium');\n\n if (el.shadowRoot.adoptedStyleSheets) {\n expect(el.shadowRoot.adoptedStyleSheets.length, 'all').to.equal(3);\n } else {\n expect(\n [...el.shadowRoot.querySelectorAll('style')].length\n ).to.equal(3);\n }\n\n // Invalid second + value fallsback to previous\n el.setAttribute('color', 'fish');\n\n await elementUpdated(el);\n expect(el.getAttribute('color')).to.equal('dark');\n\n if (el.shadowRoot.adoptedStyleSheets) {\n expect(el.shadowRoot.adoptedStyleSheets.length, 'last').to.equal(3);\n } else {\n expect(\n [...el.shadowRoot.querySelectorAll('style')].length\n ).to.equal(3);\n }\n });\n\n it('prefers system over theme', async () => {\n const el = await fixture<Theme>(html`\n <sp-theme system=\"express\"></sp-theme>\n `);\n\n await elementUpdated(el);\n\n expect(el.system).to.equal('express');\n\n el.setAttribute('theme', 'classic');\n await elementUpdated(el);\n\n expect(el.system).to.equal('express');\n expect(el.theme).to.equal('express');\n });\n});\n\ndescribe('Themes', () => {\n it('updates system value even if only theme is added to sp-theme', async () => {\n const el = await fixture<Theme>(html`\n <sp-theme theme=\"express\"></sp-theme>\n `);\n\n await elementUpdated(el);\n\n expect(el.theme).to.equal('express');\n\n el.setAttribute('theme', 'spectrum');\n await elementUpdated(el);\n\n expect(el.theme).to.equal('spectrum');\n expect(el.system).to.equal('spectrum');\n });\n it('updates system and theme value iif both are added to sp-theme', async () => {\n const el = await fixture<Theme>(html`\n <sp-theme system=\"spectrum\" theme=\"spectrum\"></sp-theme>\n `);\n\n await elementUpdated(el);\n\n expect(el.theme).to.equal('spectrum');\n expect(el.system).to.equal('spectrum');\n\n el.setAttribute('theme', 'express');\n await elementUpdated(el);\n expect(el.theme).to.equal('express');\n expect(el.system).to.equal('express');\n });\n});\n"],
5
+ "mappings": ";AAYA,OAAO;AACP,OAAO;AACP,SAAS,aAA+B;AACxC,SAAS,gBAAgB,QAAQ,SAAS,YAAY;AACtD,SAAS,WAAW;AAOpB,SAAS,WAAW,MAAM;AACtB,KAAG,iBAAiB,YAAY;AAC5B,UAAM,KAAK,MAAM,QAAe;AAAA;AAAA,SAE/B;AAED,UAAM,eAAe,EAAE;AAEvB,WAAO,EAAE,EAAE,GAAG;AACd,WAAO,EAAE,EAAE,UAAU,GAAG;AAAA,EAC5B,CAAC;AACD,KAAG,gBAAgB,YAAY;AAC3B,UAAM,KAAK,MAAM,QAAe;AAAA;AAAA,SAE/B;AAED,UAAM,eAAe,EAAE;AAEvB,WAAO,EAAE,EAAE,GAAG;AACd,WAAO,EAAE,EAAE,UAAU,GAAG;AAAA,EAC5B,CAAC;AACD,KAAG,kBAAkB,YAAY;AAC7B,UAAM,KAAK,MAAM,QAAe;AAAA;AAAA,SAE/B;AAED,UAAM,eAAe,EAAE;AAEvB,WAAO,EAAE,EAAE,GAAG;AACd,WAAO,EAAE,EAAE,UAAU,GAAG;AAAA,EAC5B,CAAC;AACD,KAAG,8BAA8B,YAAY;AACzC,UAAM,KAAK,MAAM,QAAe;AAAA;AAAA,SAE/B;AAED,UAAM,eAAe,EAAE;AACvB,UAAM,gBAAgB;AACtB,WAAO,cAAc,UAAU,IAAI,EAAE,GAAG,OAAO,EAAE,GAAG,GAAG;AACvD,WAAO,cAAc,UAAU,IAAI,EAAE,GAAG,MAAM,CAAC;AAE/C,OAAG,OAAO;AACV,WA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