Updating Text rendering to use react-testing-library

This commit is contained in:
Jeff Avallone 2019-03-24 14:54:13 -04:00
parent e449eade9d
commit f63e9b2a47
2 changed files with 70 additions and 75 deletions

View File

@ -18,47 +18,38 @@ Object {
`; `;
exports[`Text positioning text 1`] = ` exports[`Text positioning text 1`] = `
<DocumentFragment>
<svg>
<text <text
style={ style="font-size: 16px; font-family: Arial;"
Object {
"fontFamily": "Arial",
"fontSize": "16px",
}
}
transform="translate(1 2)" transform="translate(1 2)"
> >
Example Example
</text> </text>
</svg>
</DocumentFragment>
`; `;
exports[`Text rendering 1`] = ` exports[`Text rendering 1`] = `
<DocumentFragment>
<svg>
<text <text
style={ style="font-size: 16px; font-family: Arial;"
Object {
"fontFamily": "Arial",
"fontSize": "16px",
}
}
> >
Example Example
</text> </text>
</svg>
</DocumentFragment>
`; `;
exports[`Text rendering quoted text 1`] = ` exports[`Text rendering quoted text 1`] = `
<DocumentFragment>
<svg>
<text <text
style={ style="font-size: 16px; font-family: Arial;"
Object {
"fontFamily": "Arial",
"fontSize": "16px",
}
}
> >
<tspan <tspan
style={ style="fill: #908c83;"
Object {
"fill": "#908c83",
}
}
> >
</tspan> </tspan>
@ -66,27 +57,23 @@ exports[`Text rendering quoted text 1`] = `
Example Example
</tspan> </tspan>
<tspan <tspan
style={ style="fill: #908c83;"
Object {
"fill": "#908c83",
}
}
> >
</tspan> </tspan>
</text> </text>
</svg>
</DocumentFragment>
`; `;
exports[`Text rendering with a theme 1`] = ` exports[`Text rendering with a theme 1`] = `
<DocumentFragment>
<svg>
<text <text
style={ style="font-size: 16px; font-family: Arial; fill: #fff;"
Object {
"fill": "#fff",
"fontFamily": "Arial",
"fontSize": "16px",
}
}
> >
Example Example
</text> </text>
</svg>
</DocumentFragment>
`; `;

View File

@ -1,35 +1,43 @@
import React from 'react'; import React from 'react';
import { shallow } from 'enzyme'; import { render } from 'react-testing-library';
import Text, { layout } from 'rendering/Text'; import Text, { layout } from 'rendering/Text';
describe('Text', () => { describe('Text', () => {
test('rendering', () => { test('rendering', () => {
const component = shallow( const { asFragment } = render(
<svg>
<Text>Example</Text> <Text>Example</Text>
</svg>
); );
expect(component).toMatchSnapshot(); expect(asFragment()).toMatchSnapshot();
}); });
test('positioning text', () => { test('positioning text', () => {
const component = shallow( const { asFragment } = render(
<svg>
<Text transform="translate(1 2)">Example</Text> <Text transform="translate(1 2)">Example</Text>
</svg>
); );
expect(component).toMatchSnapshot(); expect(asFragment()).toMatchSnapshot();
}); });
test('rendering with a theme', () => { test('rendering with a theme', () => {
const component = shallow( const { asFragment } = render(
<svg>
<Text theme="anchor">Example</Text> <Text theme="anchor">Example</Text>
</svg>
); );
expect(component).toMatchSnapshot(); expect(asFragment()).toMatchSnapshot();
}); });
test('rendering quoted text', () => { test('rendering quoted text', () => {
const component = shallow( const { asFragment } = render(
<svg>
<Text quoted={ true }>Example</Text> <Text quoted={ true }>Example</Text>
</svg>
); );
expect(component).toMatchSnapshot(); expect(asFragment()).toMatchSnapshot();
}); });
test('layout', () => { test('layout', () => {