-
Notifications
You must be signed in to change notification settings - Fork 766
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(testing): add template rendering (#1838)
- Loading branch information
1 parent
8670bff
commit ae74a27
Showing
3 changed files
with
57 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
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,36 @@ | ||
import { Component, Prop, h } from '@stencil/core'; | ||
import { newSpecPage } from '@stencil/core/testing'; | ||
|
||
|
||
describe('jsx', () => { | ||
|
||
it('render template', async () => { | ||
@Component({ tag: 'cmp-a'}) | ||
class CmpA { | ||
@Prop() complexProp: any; | ||
render() { | ||
return <div>The answer is: {this.complexProp.value}</div>; | ||
} | ||
} | ||
|
||
const OBJECT = { value: 42 }; | ||
const MyFunctionalCmp = () => ( | ||
<cmp-a complexProp={OBJECT}></cmp-a> | ||
); | ||
|
||
const { root } = await newSpecPage({ | ||
components: [CmpA], | ||
template: () => ( | ||
<MyFunctionalCmp /> | ||
) | ||
}); | ||
|
||
expect(root).toEqualHtml(` | ||
<cmp-a> | ||
<div> | ||
The answer is: 42 | ||
</div> | ||
</cmp-a> | ||
`); | ||
}); | ||
}); |
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