Skip to content

Commit

Permalink
add test assertion for correct cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Jan 22, 2020
1 parent 77a7788 commit f2b8600
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/browser/render.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,32 @@ describe('render()', () => {
'<div>New content<button>Update</button></div>'
);
});

it('should remove redundant elements', () => {
const placeholder = document.createElement('div');
scratch.appendChild(placeholder);
const App = () => (
<div>
New content
<button>Update</button>
</div>
);

render(<App />, scratch, placeholder);
expect(scratch.innerHTML).to.equal(
'<div>New content<button>Update</button></div>'
);

placeholder.appendChild(document.createElement('span'));
expect(scratch.innerHTML).to.equal(
'<div>New content<button>Update</button><span></span></div>'
);

render(<App />, scratch, placeholder);
expect(scratch.innerHTML).to.equal(
'<div>New content<button>Update</button></div>'
);
});
});

describe('replaceNode parameter', () => {
Expand Down

0 comments on commit f2b8600

Please sign in to comment.