Skip to content

Commit

Permalink
fix(omi): unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dntzhang committed Dec 31, 2024
1 parent e957c39 commit 657bda2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/omi/test/attrs-to-props.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,9 @@ describe('attrs to props', () => {
const el = document.createElement(node.name)
parentElement.appendChild(el)
el.setProp('info', { 'age': 18 })
// will not update
// will update
el.removeAttribute('info')
expect(parentElement.firstChild.shadowRoot.innerHTML).toBe('<div>18</div>')
expect(parentElement.firstChild.shadowRoot.innerHTML).toBe('<div></div>')
})


Expand Down
5 changes: 4 additions & 1 deletion packages/omi/test/base.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ describe('base', () => {

expect(Ele.prototype.render).toHaveBeenCalledTimes(1)
expect(Ele.prototype.render).toHaveBeenCalledWith(
{ ignoreAttrs: true },
{
children: [],
ignoreAttrs: true
},
undefined
)
expect(Ele.prototype.render).toHaveReturnedWith(
Expand Down
2 changes: 1 addition & 1 deletion packages/omi/test/svg.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('index', () => {
render(<my-svg />, parentElement)

expect(Ele.prototype.render).toHaveBeenCalledTimes(1)
expect(Ele.prototype.render).toHaveBeenCalledWith({ 'ignoreAttrs': true }, undefined)
expect(Ele.prototype.render).toHaveBeenCalledWith({ 'ignoreAttrs': true, children: [] }, undefined)
expect(Ele.prototype.render).toHaveReturnedWith(expect.objectContaining({ nodeName: 'svg' }))

expect(parentElement.firstChild.shadowRoot.innerHTML).toBe('<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><polygon points="5,5 195,10 185,185 10,195" fill="red"></polygon><foreignObject x="20" y="20" width="160" height="160"><div xmlns="http://www.w3.org/1999/xhtml">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed mollis mollis mi ut ultricies. Nullam magna ipsum, porta vel dui convallis, rutrum imperdiet eros. Aliquam erat volutpat.</div></foreignObject></svg>')
Expand Down

0 comments on commit 657bda2

Please sign in to comment.