-
Notifications
You must be signed in to change notification settings - Fork 396
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add more tests for light DOM inheritance (#2462)
- Loading branch information
1 parent
1bc6c1c
commit 680ae52
Showing
15 changed files
with
52 additions
and
16 deletions.
There are no files selected for viewing
30 changes: 24 additions & 6 deletions
30
packages/integration-karma/test/light-dom/inheritance/index.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 |
---|---|---|
@@ -1,16 +1,34 @@ | ||
import { createElement, setFeatureFlagForTest } from 'lwc'; | ||
|
||
import Test from 'x/test'; | ||
import ShadowExtendsLight from 'x/shadowExtendsLight'; | ||
import DefaultExtendsLight from 'x/defaultExtendsLight'; | ||
import LightExtendsShadow from 'x/lightExtendsShadow'; | ||
import DefaultExtendsShadow from 'x/defaultExtendsShadow'; | ||
|
||
describe('with base class light and subclass shadow', () => { | ||
describe('light/shadow inheritance from base classes', () => { | ||
beforeEach(() => { | ||
setFeatureFlagForTest('ENABLE_LIGHT_DOM_COMPONENTS', true); | ||
}); | ||
afterEach(() => { | ||
setFeatureFlagForTest('ENABLE_LIGHT_DOM_COMPONENTS', false); | ||
}); | ||
it('should render properly', () => { | ||
const elm = createElement('x-test', { is: Test }); | ||
expect(elm.shadowRoot).not.toBeNull(); | ||
}); | ||
|
||
const testCases = [ | ||
{ tag: 'x-shadow-extends-light', is: ShadowExtendsLight, shadow: true }, | ||
{ tag: 'x-default-extends-light', is: DefaultExtendsLight, shadow: false }, | ||
{ tag: 'x-light-extends-shadow', is: LightExtendsShadow, shadow: false }, | ||
{ tag: 'x-default-extends-shadow', is: DefaultExtendsShadow, shadow: true }, | ||
]; | ||
|
||
for (const { tag, is, shadow } of testCases) { | ||
it(`renders ${is.name}`, () => { | ||
const elm = createElement(tag, { is }); | ||
document.body.appendChild(elm); | ||
if (shadow) { | ||
expect(elm.shadowRoot).not.toBeNull(); | ||
} else { | ||
expect(elm.shadowRoot).toBeNull(); | ||
} | ||
}); | ||
} | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/integration-karma/test/light-dom/inheritance/x/baseLight/baseLight.html
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 @@ | ||
<template lwc:render-mode="light"></template> |
2 changes: 1 addition & 1 deletion
2
...test/light-dom/inheritance/x/base/base.js → ...-dom/inheritance/x/baseLight/baseLight.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
export default class Base extends LightningElement { | ||
export default class BaseLight extends LightningElement { | ||
static renderMode = 'light'; | ||
} |
1 change: 1 addition & 0 deletions
1
packages/integration-karma/test/light-dom/inheritance/x/baseShadow/baseShadow.html
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 @@ | ||
<template></template> |
3 changes: 3 additions & 0 deletions
3
packages/integration-karma/test/light-dom/inheritance/x/baseShadow/baseShadow.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,3 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
export default class BaseShadow extends LightningElement {} |
1 change: 1 addition & 0 deletions
1
...tegration-karma/test/light-dom/inheritance/x/defaultExtendsLight/defaultExtendsLight.html
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 @@ | ||
<template lwc:render-mode="light"></template> |
3 changes: 3 additions & 0 deletions
3
...integration-karma/test/light-dom/inheritance/x/defaultExtendsLight/defaultExtendsLight.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,3 @@ | ||
import BaseLight from 'x/baseLight'; | ||
|
||
export default class DefaultExtendsLight extends BaseLight {} |
1 change: 1 addition & 0 deletions
1
...gration-karma/test/light-dom/inheritance/x/defaultExtendsShadow/defaultExtendsShadow.html
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 @@ | ||
<template></template> |
3 changes: 3 additions & 0 deletions
3
...tegration-karma/test/light-dom/inheritance/x/defaultExtendsShadow/defaultExtendsShadow.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,3 @@ | ||
import BaseShadow from 'x/baseShadow'; | ||
|
||
export default class DefaultExtendsShadow extends BaseShadow {} |
2 changes: 1 addition & 1 deletion
2
...st/light-dom/inheritance/x/base/base.html → ...ightExtendsShadow/lightExtendsShadow.html
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<template lwc:render-mode="light"> | ||
<x-test data-id="x-test"></x-test> | ||
<p></p> | ||
</template> |
5 changes: 5 additions & 0 deletions
5
...s/integration-karma/test/light-dom/inheritance/x/lightExtendsShadow/lightExtendsShadow.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,5 @@ | ||
import BaseShadow from 'x/baseShadow'; | ||
|
||
export default class LightExtendsShadow extends BaseShadow { | ||
static renderMode = 'light'; | ||
} |
3 changes: 3 additions & 0 deletions
3
...integration-karma/test/light-dom/inheritance/x/shadowExtendsLight/shadowExtendsLight.html
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> | ||
<p></p> | ||
</template> |
5 changes: 5 additions & 0 deletions
5
...s/integration-karma/test/light-dom/inheritance/x/shadowExtendsLight/shadowExtendsLight.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,5 @@ | ||
import BaseLight from 'x/baseLight'; | ||
|
||
export default class ShadowExtendsLight extends BaseLight { | ||
static renderMode = 'shadow'; | ||
} |
3 changes: 0 additions & 3 deletions
3
packages/integration-karma/test/light-dom/inheritance/x/test/test.html
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
packages/integration-karma/test/light-dom/inheritance/x/test/test.js
This file was deleted.
Oops, something went wrong.