Skip to content

Commit

Permalink
added another test case for parsing multiple root elements
Browse files Browse the repository at this point in the history
  • Loading branch information
oroce committed Feb 13, 2017
1 parent cc39ebc commit f015841
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion test/html-to-react-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,22 @@ describe('Html2React', function () {
});

describe('parse multiple elements', function() {
it('should throw an error when trying parsing multiple root elements', function () {
it('should parse multiple root elements', function () {
var htmlInput = '<div></div><div></div>';
var components = parser.parse(htmlInput);
var output = components.map(function (component) {
return ReactDOMServer.renderToStaticMarkup(component);
}).join('');
assert.equal(htmlInput, output);
});

it('should be able to parse and render multiple children elements', function() {
var htmlInput = '<li>first</li><li>second</li><li>third</li>';
var components = parser.parse(htmlInput);
var output = ReactDOMServer.renderToStaticMarkup(
React.createElement('ul', null, components)
);
assert.equal('<ul>' + htmlInput + '</ul>', output);
});
});
});

0 comments on commit f015841

Please sign in to comment.