Tests for SVG rendering component

This commit is contained in:
Jeff Avallone 2019-01-31 21:19:19 -05:00
parent 47ee62d387
commit 8830fad923
2 changed files with 90 additions and 0 deletions

View File

@ -0,0 +1,61 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`SVG layout 1`] = `
Object {
"box": Object {
"height": 40,
"width": 120,
},
"children": Array [
Object {
"box": Object {
"height": 20,
"width": 100,
},
"type": "Text",
},
],
"props": Object {
"height": 40,
"width": 120,
},
"type": "SVG",
}
`;
exports[`SVG rendering 1`] = `
<svg
height={20}
style={
Object {
"backgroundColor": "#fff",
}
}
viewBox="0 0 100 20"
width={100}
xmlns="http://www.w3.org/2000/svg"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>
<metadata
dangerouslySetInnerHTML={
Object {
"__html": "<rdf:rdf>
<cc:license rdf:about=\\"http://creativecommons.org/licenses/by/3.0/\\">
<cc:permits rdf:resource=\\"http://creativecommons.org/ns#Reproduction\\"></cc:permits>
<cc:permits rdf:resource=\\"http://creativecommons.org/ns#Distribution\\"></cc:permits>
<cc:requires rdf:resource=\\"http://creativecommons.org/ns#Notice\\"></cc:requires>
<cc:requires rdf:resource=\\"http://creativecommons.org/ns#Attribution\\"></cc:requires>
<cc:permits rdf:resource=\\"http://creativecommons.org/ns#DerivativeWorks\\"></cc:permits>
</cc:license>
</rdf:rdf>",
}
}
/>
<g
transform="translate(10 10)"
>
Content
</g>
</svg>
`;

29
src/rendering/SVG/test.js Normal file
View File

@ -0,0 +1,29 @@
import React from 'react';
import { shallow } from 'enzyme';
import SVG, { layout } from 'rendering/SVG';
describe('SVG', () => {
test('rendering', () => {
const component = shallow(
<SVG width={ 100 } height={ 20 }>Content</SVG>
);
expect(component).toMatchSnapshot();
});
test('layout', () => {
const processed = layout({
type: 'SVG',
children: [
{
type: 'Text',
box: {
width: 100,
height: 20
}
}
]
});
expect(processed).toMatchSnapshot();
});
});