Skip to content

Commit

Permalink
Add tests to cover use cases for a link element | Fixes metal#371
Browse files Browse the repository at this point in the history
  • Loading branch information
matuzalemsteles committed Apr 24, 2018
1 parent 8d8b8c4 commit 474403d
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions packages/metal-incremental-dom/test/html/HTML2IncDom.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,49 @@ describe('HTML2IncDom', function() {
assert.strictEqual(htmlStr, element.innerHTML);
});

it('should render a link element with inline elements inside via incremental dom', function() {
let element = document.createElement('div');
let htmlStr = '<a href="http://foo.com"><strong><b>Foo</b></strong></a>';
IncrementalDOM.patch(element, () => HTML2IncDom.run(htmlStr));

assert.strictEqual(htmlStr, element.innerHTML);
});

it('should render a link element within inline elements via incremental dom', function() {
let element = document.createElement('div');
let htmlStr = '<strong><b><a href="http://foo.com">Foo</a></b></strong>';
IncrementalDOM.patch(element, () => HTML2IncDom.run(htmlStr));

assert.strictEqual(htmlStr, element.innerHTML);
});

it('should render a link element inside inline and block elements via incremental dom', function() {
let element = document.createElement('div');
let htmlStr =
'<p><strong><b><a href="http://foo.com">Foo</a></b></strong></p>';
IncrementalDOM.patch(element, () => HTML2IncDom.run(htmlStr));

assert.strictEqual(htmlStr, element.innerHTML);
});

it('should render a link element with inline elements inside and inside a block element via incremental dom', function() {
let element = document.createElement('div');
let htmlStr =
'<div><a href="http://foo.com"><strong><b>Foo</b></strong></a></div>';
IncrementalDOM.patch(element, () => HTML2IncDom.run(htmlStr));

assert.strictEqual(htmlStr, element.innerHTML);
});

it('should render a link element with block elements inside via incremental dom', function() {
let element = document.createElement('div');
let htmlStr =
'<a href="http://foo.com"><div><strong><b>Foo</b></strong></div></a>';
IncrementalDOM.patch(element, () => HTML2IncDom.run(htmlStr));

assert.strictEqual(htmlStr, element.innerHTML);
});

it('should render escaped html inside element via incremental dom', function() {
let element = document.createElement('div');
IncrementalDOM.patch(element, () => HTML2IncDom.run('&#39;Foo&#39;'));
Expand Down

0 comments on commit 474403d

Please sign in to comment.