|
1 | | -import { createElement, setFeatureFlagForTest } from 'lwc'; |
2 | | -import Container from './x/container/container'; |
| 1 | +import { createElement } from 'lwc'; |
3 | 2 | import MultipleStyles from './x/multipleStyles/multipleStyles'; |
4 | 3 | import SvgNs from './x/svgNs/svgNs'; |
5 | 4 |
|
6 | | -if (!process.env.NATIVE_SHADOW && !process.env.COMPAT) { |
7 | | - /* compat will have the token when rendering in native*/ describe('Mixed mode for static content', () => { |
8 | | - beforeEach(() => { |
9 | | - setFeatureFlagForTest('ENABLE_MIXED_SHADOW_MODE', true); |
10 | | - }); |
11 | | - afterEach(() => { |
12 | | - setFeatureFlagForTest('ENABLE_MIXED_SHADOW_MODE', false); |
13 | | - }); |
14 | | - |
15 | | - ['native', 'synthetic'].forEach((firstRenderMode) => { |
16 | | - it(`should set the tokens for synthetic shadow when it renders first in ${firstRenderMode}`, () => { |
17 | | - const elm = createElement('x-container', { is: Container }); |
18 | | - elm.syntheticFirst = firstRenderMode === 'synthetic'; |
19 | | - document.body.appendChild(elm); |
| 5 | +describe('static content when stylesheets change', () => { |
| 6 | + it('should reflect correct token for scoped styles', () => { |
| 7 | + const elm = createElement('x-container', { is: MultipleStyles }); |
20 | 8 |
|
21 | | - const syntheticMode = elm.shadowRoot |
22 | | - .querySelector('x-component') |
23 | | - .shadowRoot.querySelector('div'); |
24 | | - const nativeMode = elm.shadowRoot |
25 | | - .querySelector('x-native') |
26 | | - .shadowRoot.querySelector('x-component') |
27 | | - .shadowRoot.querySelector('div'); |
| 9 | + const stylesheetsWarning = |
| 10 | + /Dynamically setting the "stylesheets" property on a template function is deprecated and may be removed in a future version of LWC./; |
28 | 11 |
|
29 | | - expect(syntheticMode.hasAttribute('x-component_component')).toBe(true); |
30 | | - expect(nativeMode.hasAttribute('x-component_component')).toBe(false); |
| 12 | + expect(() => { |
| 13 | + elm.updateTemplate({ |
| 14 | + name: 'a', |
| 15 | + useScopedCss: false, |
31 | 16 | }); |
32 | | - }); |
33 | | - }); |
34 | | -} |
| 17 | + }).toLogErrorDev(stylesheetsWarning); |
35 | 18 |
|
36 | | -describe('static content when stylesheets change', () => { |
37 | | - it('should reflect correct token for scoped styles', () => { |
38 | | - const elm = createElement('x-container', { is: MultipleStyles }); |
39 | 19 | document.body.appendChild(elm); |
40 | 20 |
|
41 | 21 | expect(elm.shadowRoot.querySelector('div').getAttribute('class')).toBe('foo'); |
42 | 22 |
|
43 | 23 | // atm, we need to switch templates. |
44 | | - elm.tpl = 'b'; |
45 | | - elm.useScopeCss = true; |
| 24 | + expect(() => { |
| 25 | + elm.updateTemplate({ |
| 26 | + name: 'b', |
| 27 | + useScopedCss: true, |
| 28 | + }); |
| 29 | + }).toLogErrorDev(stylesheetsWarning); |
46 | 30 |
|
47 | 31 | return Promise.resolve() |
48 | 32 | .then(() => { |
49 | | - expect(elm.shadowRoot.querySelector('div').getAttribute('class')).toBe( |
50 | | - 'foo x-multipleStyles_b' |
51 | | - ); |
52 | | - elm.tpl = 'a'; |
53 | | - elm.useScopeCss = false; |
| 33 | + const classList = Array.from(elm.shadowRoot.querySelector('div').classList).sort(); |
| 34 | + expect(classList).toEqual(['foo', 'x-multipleStyles_b']); |
| 35 | + |
| 36 | + expect(() => { |
| 37 | + elm.updateTemplate({ |
| 38 | + name: 'a', |
| 39 | + useScopedCss: false, |
| 40 | + }); |
| 41 | + }).toLogErrorDev(stylesheetsWarning); |
54 | 42 | }) |
55 | 43 | .then(() => { |
56 | | - expect(elm.shadowRoot.querySelector('div').getAttribute('class')).toBe('foo'); |
| 44 | + const classList = Array.from(elm.shadowRoot.querySelector('div').classList).sort(); |
| 45 | + expect(classList).toEqual(['foo']); |
57 | 46 | }); |
58 | 47 | }); |
59 | 48 | }); |
|
0 commit comments