Skip to content

Commit

Permalink
fix: added test case for viewBox
Browse files Browse the repository at this point in the history
  • Loading branch information
phawxby committed May 11, 2018
1 parent 17db9f3 commit 261ffb7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions test/dom-to-react.js
Expand Up @@ -128,4 +128,14 @@ describe('dom-to-react parser', function() {
);
});


it('handles svg\'s with a viewBox', function() {
var html = mocks.html.svg;
var reactElement = domToReact(htmlToDOM(html));

assert.deepEqual(
reactElement,
React.createElement('svg', { viewBox: '0 0 512 512', id: 'foo' }, 'Inner')
);
});
});
3 changes: 2 additions & 1 deletion test/helpers/mocks.json
Expand Up @@ -11,7 +11,8 @@
"img": "<img src=\"http://stat.ic/img.jpg\" alt=\"Image\"/>",
"void": "<link/><meta/><img/><br/><hr/><input/>",
"comment": "<!-- comment -->",
"doctype": "<!DOCTYPE html>"
"doctype": "<!DOCTYPE html>",
"svg": "<svg viewBox=\"0 0 512 512\" id=\"foo\">Inner</svg>"
},
"svg": {
"complex": "<svg height=\"400\" width=\"450\"><path id=\"lineAB\" d=\"M 100 350 l 150 -300\" stroke=\"red\" stroke-width=\"3\" fill=\"none\"></path><g stroke=\"black\" stroke-width=\"3\" fill=\"black\"><circle id=\"pointA\" cx=\"100\" cy=\"350\" r=\"3\"></circle></g><g font-size=\"30\" font-family=\"sans-serif\" fill=\"black\" stroke=\"none\" text-anchor=\"middle\"><text x=\"100\" y=\"350\" dx=\"-30\">A</text></g>Your browser does not support inline SVG.</svg>"
Expand Down

0 comments on commit 261ffb7

Please sign in to comment.