Skip to content

Commit

Permalink
test(omi): more testing of rendering function
Browse files Browse the repository at this point in the history
  • Loading branch information
dntzhang committed Jan 12, 2024
1 parent aa7143d commit 085c134
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion packages/omi/test/base.test.jsx
Expand Up @@ -442,7 +442,7 @@ describe('base', () => {

})

it('rendering function', () => {
it('rendering function 1', () => {

function ChildComponent(props) {
return (
Expand All @@ -465,4 +465,37 @@ describe('base', () => {
expect(parentElement.firstChild.shadowRoot.firstChild.innerHTML).toBe('<span>omi</span>')

})

it('rendering function 2', () => {

function ChildComponent(props) {
return (
<span>{props.msg}</span>
)
}

class ParentComponent extends Component {
state = {
msg: 'omi'
}

render() {
return (
<div>
<ChildComponent msg={this.state.msg} />
</div>
)
}

installed() {
this.state.msg = 'Hello omi'
this.update()
}
}
let node = genNode()
define(node.name, ParentComponent)
render(<ParentComponent />, parentElement)
expect(parentElement.firstChild.shadowRoot.firstChild.innerHTML).toBe('<span>Hello omi</span>')

})
})

0 comments on commit 085c134

Please sign in to comment.