Skip to content

Commit 261ffb7

Browse files
committed
fix: added test case for viewBox
1 parent 17db9f3 commit 261ffb7

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

test/dom-to-react.js

+10
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,14 @@ describe('dom-to-react parser', function() {
128128
);
129129
});
130130

131+
132+
it('handles svg\'s with a viewBox', function() {
133+
var html = mocks.html.svg;
134+
var reactElement = domToReact(htmlToDOM(html));
135+
136+
assert.deepEqual(
137+
reactElement,
138+
React.createElement('svg', { viewBox: '0 0 512 512', id: 'foo' }, 'Inner')
139+
);
140+
});
131141
});

test/helpers/mocks.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"img": "<img src=\"http://stat.ic/img.jpg\" alt=\"Image\"/>",
1212
"void": "<link/><meta/><img/><br/><hr/><input/>",
1313
"comment": "<!-- comment -->",
14-
"doctype": "<!DOCTYPE html>"
14+
"doctype": "<!DOCTYPE html>",
15+
"svg": "<svg viewBox=\"0 0 512 512\" id=\"foo\">Inner</svg>"
1516
},
1617
"svg": {
1718
"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>"

0 commit comments

Comments
 (0)