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

View File

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