-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(integration-karma): template expressions
- Loading branch information
Showing
13 changed files
with
78 additions
and
0 deletions.
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
16 changes: 16 additions & 0 deletions
16
packages/@lwc/integration-karma/test/template-expressions/errors/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,16 @@ | ||
import { createElement } from 'lwc'; | ||
|
||
import UndefinedMemberExpressionObjParent from 'x/undefinedMemberExpressionObjParent'; | ||
import ThrowDuringCallParent from 'x/throwDuringCallParent'; | ||
|
||
it(`should handle member expression with undefined object`, () => { | ||
const parent = createElement('x-parent', { is: UndefinedMemberExpressionObjParent }); | ||
document.body.appendChild(parent); | ||
expect(parent.caughtError).toContain('undefined'); | ||
}); | ||
|
||
it(`should handle errors thrown during call expression`, () => { | ||
const parent = createElement('x-parent', { is: ThrowDuringCallParent }); | ||
document.body.appendChild(parent); | ||
expect(parent.caughtError).toContain("I'm the Gingerbread man!"); | ||
}); |
3 changes: 3 additions & 0 deletions
3
...n-karma/test/template-expressions/errors/x/throwDuringCallChild/throwDuringCallChild.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> | ||
<div foo={runRunAsFastAsYouCan()}></div> | ||
</template> |
7 changes: 7 additions & 0 deletions
7
...ion-karma/test/template-expressions/errors/x/throwDuringCallChild/throwDuringCallChild.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,7 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
export default class Test extends LightningElement { | ||
runRunAsFastAsYouCan() { | ||
throw new Error("You can't catch me, I'm the Gingerbread man!"); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...karma/test/template-expressions/errors/x/throwDuringCallParent/throwDuringCallParent.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> | ||
<x-throw-during-call-child></x-throw-during-call-child> | ||
</template> |
8 changes: 8 additions & 0 deletions
8
...n-karma/test/template-expressions/errors/x/throwDuringCallParent/throwDuringCallParent.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,8 @@ | ||
import { LightningElement, api } from 'lwc'; | ||
|
||
export default class Parent extends LightningElement { | ||
@api caughtError = null; | ||
errorCallback(err) { | ||
this.caughtError = err.message; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...essions/errors/x/undefinedMemberExpressionObjChild/undefinedMemberExpressionObjChild.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> | ||
<div foo={nonexistent.thing}></div> | ||
</template> |
3 changes: 3 additions & 0 deletions
3
...pressions/errors/x/undefinedMemberExpressionObjChild/undefinedMemberExpressionObjChild.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 Test extends LightningElement {} |
3 changes: 3 additions & 0 deletions
3
...sions/errors/x/undefinedMemberExpressionObjParent/undefinedMemberExpressionObjParent.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> | ||
<x-undefined-member-expression-obj-child></x-undefined-member-expression-obj-child> | ||
</template> |
8 changes: 8 additions & 0 deletions
8
...essions/errors/x/undefinedMemberExpressionObjParent/undefinedMemberExpressionObjParent.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,8 @@ | ||
import { LightningElement, api } from 'lwc'; | ||
|
||
export default class Parent extends LightningElement { | ||
@api caughtError = null; | ||
errorCallback(err) { | ||
this.caughtError = err.message; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/@lwc/integration-karma/test/template-expressions/smoke-test/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,10 @@ | ||
import { createElement } from 'lwc'; | ||
|
||
import Test from 'x/test'; | ||
|
||
it(`should support call expressions`, () => { | ||
const elm = createElement('x-test', { is: Test }); | ||
document.body.appendChild(elm); | ||
|
||
expect(elm.shadowRoot.querySelector('div').getAttribute('foo')).toBe('bar'); | ||
}); |
3 changes: 3 additions & 0 deletions
3
packages/@lwc/integration-karma/test/template-expressions/smoke-test/x/test/test.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> | ||
<div foo={bar()}></div> | ||
</template> |
7 changes: 7 additions & 0 deletions
7
packages/@lwc/integration-karma/test/template-expressions/smoke-test/x/test/test.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,7 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
export default class Test extends LightningElement { | ||
bar() { | ||
return 'bar'; | ||
} | ||
} |