Skip to content

Commit 006d5c2

Browse files
Add tests for SVG to React conversion
1 parent 889623e commit 006d5c2

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

test/data.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@
66
"textarea": "<textarea>foo</textarea>",
77
"script": "<script>alert(1 < 2);</script>",
88
"comment": "<!-- comment -->"
9+
},
10+
"svg": {
11+
"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>"
912
}
1013
}

test/html-to-react.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,10 @@ describe('html-to-react parser', function() {
5252
assert.equal(render(reactElement), html);
5353
});
5454

55+
it('converts SVG to React', function() {
56+
var svg = data.svg.complex;
57+
var reactElement = Parser(svg);
58+
assert.equal(render(reactElement), svg);
59+
});
60+
5561
});

0 commit comments

Comments
 (0)