Adding some initial tests for Render component

This commit is contained in:
Jeff Avallone 2019-01-31 21:51:53 -05:00
parent b7393b3a4b
commit b3b7480358
2 changed files with 270 additions and 0 deletions

View File

@ -0,0 +1,155 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Render debugging 1`] = `
<div
className="render"
>
<SVG
onReflow={[Function]}
>
<Text>
Example
</Text>
<rect
height={50}
style={
Object {
"fill": "transparent",
"opacity": 0.5,
"stroke": "red",
"strokeDasharray": "2,2",
"strokeWidth": "1px",
}
}
width={100}
/>
<circle
cx={5}
cy={10}
r="3"
style={
Object {
"fill": "red",
"opacity": 0.5,
}
}
/>
<circle
cx={95}
cy={10}
r="3"
style={
Object {
"fill": "red",
"opacity": 0.5,
}
}
/>
</SVG>
</div>
`;
exports[`Render types Box 1`] = `
<div
className="render"
>
<SVG
onReflow={[Function]}
>
<Box
padding={5}
radius={3}
>
<Text>
Example
</Text>
</Box>
</SVG>
</div>
`;
exports[`Render types HorizontalLayout 1`] = `
<div
className="render"
>
<SVG
onReflow={[Function]}
>
<HorizontalLayout
spacing={10}
withConnectors={false}
>
<Text>
Example
</Text>
<Text>
Another Example
</Text>
</HorizontalLayout>
</SVG>
</div>
`;
exports[`Render types Loop 1`] = `
<div
className="render"
>
<SVG
onReflow={[Function]}
>
<Loop>
<Text>
Example
</Text>
</Loop>
</SVG>
</div>
`;
exports[`Render types Pin 1`] = `
<div
className="render"
>
<SVG
onReflow={[Function]}
>
<Pin />
</SVG>
</div>
`;
exports[`Render types Text 1`] = `
<div
className="render"
>
<SVG
onReflow={[Function]}
>
<Text>
Example
</Text>
</SVG>
</div>
`;
exports[`Render types VerticalLayout 1`] = `
<div
className="render"
>
<SVG
onReflow={[Function]}
>
<VerticalLayout
spacing={10}
withConnectors={false}
>
<Text>
Example
</Text>
<Text>
Another Example
</Text>
</VerticalLayout>
</SVG>
</div>
`;

View File

@ -0,0 +1,115 @@
import React from 'react';
import { shallow } from 'enzyme';
import Render from 'components/Render';
const testType = (name, item) => {
test(name, () => {
const data = { type: 'SVG', children: [item] };
const component = shallow(
<Render data={ data } onRender={ jest.fn() }/>
);
expect(component).toMatchSnapshot();
});
};
describe('Render', () => {
test('debugging', () => {
const data = {
type: 'SVG',
children: [
{
type: 'Text',
debug: true,
box: {
width: 100,
height: 50,
axisY: 10,
axisX1: 5,
axisX2: 95
},
children: [
'Example'
]
}
]
};
const component = shallow(
<Render data={ data } onRender={ jest.fn() }/>
);
expect(component).toMatchSnapshot();
});
describe('types', () => {
testType('Pin', {
type: 'Pin'
});
testType('Text', {
type: 'Text',
children: [
'Example'
]
});
testType('Box', {
type: 'Box',
children: [
{
type: 'Text',
children: [
'Example'
]
}
]
});
testType('Loop', {
type: 'Loop',
children: [
{
type: 'Text',
children: [
'Example'
]
}
]
});
testType('HorizontalLayout', {
type: 'HorizontalLayout',
children: [
{
type: 'Text',
children: [
'Example'
]
},
{
type: 'Text',
children: [
'Another Example'
]
}
]
});
testType('VerticalLayout', {
type: 'VerticalLayout',
children: [
{
type: 'Text',
children: [
'Example'
]
},
{
type: 'Text',
children: [
'Another Example'
]
}
]
});
});
});