-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(serializer): test CSS scope tokens (#183)
- Loading branch information
1 parent
adbdc76
commit a73e0f4
Showing
5 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
test/src/modules/serializer/styled/__tests__/styled.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
`); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
h1 { | ||
color: red; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
<h1>I am an LWC component</h1> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
h1 { | ||
background: blue; | ||
} |