-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: error from disconnecting an already disconnected vm (#1413)
* fix: error from disconnecting an already disconnected vm https://playground.lwcjs.org/projects/S_7PCquA7/3/edit * fix: add tests for disconnecting rootVM * fix: simplify test
- Loading branch information
Showing
6 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
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
20 changes: 20 additions & 0 deletions
20
packages/integration-karma/test/rendering/disconnecting-root-vm/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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { createElement } from 'lwc'; | ||
import ParentCmp from 'x/parent'; | ||
|
||
describe('disconnecting root vm', () => { | ||
it('should not throw an error when disconnecting an already disconnected child vm', function(done) { | ||
const elm = createElement('x-parent', { is: ParentCmp }); | ||
elm.labels = ['label 1', 'label 2']; | ||
document.body.appendChild(elm); | ||
|
||
return Promise.resolve().then(() => { | ||
elm.labels = []; | ||
document.body.removeChild(elm); | ||
|
||
setTimeout(() => { | ||
expect(elm.getError()).toBe(null); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
3 changes: 3 additions & 0 deletions
3
packages/integration-karma/test/rendering/disconnecting-root-vm/x/child/child.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> | ||
{label} | ||
</template> |
5 changes: 5 additions & 0 deletions
5
packages/integration-karma/test/rendering/disconnecting-root-vm/x/child/child.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 { LightningElement, api } from 'lwc'; | ||
|
||
export default class ChildCmp extends LightningElement { | ||
@api label; | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/integration-karma/test/rendering/disconnecting-root-vm/x/parent/parent.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,5 @@ | ||
<template> | ||
<template for:each={labels} for:item="label"> | ||
<x-child key={label} label={label}></x-child> | ||
</template> | ||
</template> |
14 changes: 14 additions & 0 deletions
14
packages/integration-karma/test/rendering/disconnecting-root-vm/x/parent/parent.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,14 @@ | ||
import { LightningElement, api } from 'lwc'; | ||
|
||
export default class ParentCmp extends LightningElement { | ||
@api labels = []; | ||
_error = null; | ||
|
||
@api getError() { | ||
return this._error; | ||
} | ||
|
||
errorCallback(error) { | ||
this._error = error; | ||
} | ||
} |