Skip to content

Commit

Permalink
test(serializer): test CSS scope tokens (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson authored Jun 5, 2023
1 parent adbdc76 commit a73e0f4
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
53 changes: 53 additions & 0 deletions test/src/modules/serializer/styled/__tests__/styled.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { createElement } from 'lwc';
import Styled from '../styled';

it('serializes component with HTML - styled in native shadow', () => {
const elm = createElement('serializer-component', { is: Styled });
document.body.appendChild(elm);

if (global['lwc-jest'].nativeShadow) {
expect(elm).toMatchInlineSnapshot(`
<serializer-component
class="x-test_styled-host"
>
#shadow-root(open)
<style
type="text/css"
>
h1 {color: red;}
</style>
<style
type="text/css"
>
h1.x-test_styled {background: blue;}
</style>
<h1
class="x-test_styled"
>
I am an LWC component
</h1>
</serializer-component>
`);
} else {
expect(elm).toMatchInlineSnapshot(`
<serializer-component
class="x-test_styled-host"
x-test_styled-host=""
>
#shadow-root(open)
<h1
class="x-test_styled"
x-test_styled=""
>
I am an LWC component
</h1>
</serializer-component>
`);
}
});
3 changes: 3 additions & 0 deletions test/src/modules/serializer/styled/styled.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
h1 {
color: red;
}
3 changes: 3 additions & 0 deletions test/src/modules/serializer/styled/styled.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<h1>I am an LWC component</h1>
</template>
11 changes: 11 additions & 0 deletions test/src/modules/serializer/styled/styled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/

import { LightningElement } from 'lwc';

export default class extends LightningElement {
}
3 changes: 3 additions & 0 deletions test/src/modules/serializer/styled/styled.scoped.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
h1 {
background: blue;
}

0 comments on commit a73e0f4

Please sign in to comment.