mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Added unit Tests in the ReactART, increasing the code coverage (#23195)
This commit is contained in:
@@ -440,6 +440,60 @@ describe('ReactARTComponents', () => {
|
||||
expect(rectangle.toJSON()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should generate a <Shape> with positive width when width prop is negative', () => {
|
||||
const rectangle = ReactTestRenderer.create(
|
||||
<Rectangle width={-50} height={50} />,
|
||||
);
|
||||
expect(rectangle.toJSON()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should generate a <Shape> with positive height when height prop is negative', () => {
|
||||
const rectangle = ReactTestRenderer.create(
|
||||
<Rectangle height={-50} width={50} />,
|
||||
);
|
||||
expect(rectangle.toJSON()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should generate a <Shape> with a radius property of 0 when top left radius prop is negative', () => {
|
||||
const rectangle = ReactTestRenderer.create(
|
||||
<Rectangle radiusTopLeft={-25} width={50} height={50} />,
|
||||
);
|
||||
expect(rectangle.toJSON()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should generate a <Shape> with a radius property of 0 when top right radius prop is negative', () => {
|
||||
const rectangle = ReactTestRenderer.create(
|
||||
<Rectangle radiusTopRight={-25} width={50} height={50} />,
|
||||
);
|
||||
expect(rectangle.toJSON()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should generate a <Shape> with a radius property of 0 when bottom right radius prop is negative', () => {
|
||||
const rectangle = ReactTestRenderer.create(
|
||||
<Rectangle radiusBottomRight={-30} width={50} height={50} />,
|
||||
);
|
||||
expect(rectangle.toJSON()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should generate a <Shape> with a radius property of 0 when bottom left radius prop is negative', () => {
|
||||
const rectangle = ReactTestRenderer.create(
|
||||
<Rectangle radiusBottomLeft={-25} width={50} height={50} />,
|
||||
);
|
||||
expect(rectangle.toJSON()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should generate a <Shape> where top radius is 0 if the sum of the top radius is greater than width', () => {
|
||||
const rectangle = ReactTestRenderer.create(
|
||||
<Rectangle
|
||||
radiusTopRight={25}
|
||||
radiusTopLeft={26}
|
||||
width={50}
|
||||
height={40}
|
||||
/>,
|
||||
);
|
||||
expect(rectangle.toJSON()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should warn if width/height is missing on a Rectangle component', () => {
|
||||
expect(() =>
|
||||
ReactTestRenderer.create(<Rectangle stroke="green" fill="blue" />),
|
||||
|
||||
@@ -1,5 +1,174 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`ReactARTComponents should generate a <Shape> where top radius is 0 if the sum of the top radius is greater than width 1`] = `
|
||||
<Shape
|
||||
d={
|
||||
Object {
|
||||
"_pivotX": 0,
|
||||
"_pivotY": 0,
|
||||
"path": Array [
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
],
|
||||
"penDownX": 0,
|
||||
"penDownY": 0,
|
||||
"penX": 0,
|
||||
"penY": 0,
|
||||
}
|
||||
}
|
||||
height={40}
|
||||
radiusTopLeft={26}
|
||||
radiusTopRight={25}
|
||||
width={50}
|
||||
/>
|
||||
`;
|
||||
exports[`ReactARTComponents should generate a <Shape> with a radius property of 0 when bottom left radius prop is negative 1`] = `
|
||||
<Shape
|
||||
d={
|
||||
Object {
|
||||
"_pivotX": 0,
|
||||
"_pivotY": 0,
|
||||
"path": Array [
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
],
|
||||
"penDownX": 0,
|
||||
"penDownY": 0,
|
||||
"penX": 0,
|
||||
"penY": 0,
|
||||
}
|
||||
}
|
||||
height={50}
|
||||
radiusBottomLeft={-25}
|
||||
width={50}
|
||||
/>
|
||||
`;
|
||||
exports[`ReactARTComponents should generate a <Shape> with a radius property of 0 when bottom right radius prop is negative 1`] = `
|
||||
<Shape
|
||||
d={
|
||||
Object {
|
||||
"_pivotX": 0,
|
||||
"_pivotY": 0,
|
||||
"path": Array [
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
],
|
||||
"penDownX": 0,
|
||||
"penDownY": 0,
|
||||
"penX": 0,
|
||||
"penY": 0,
|
||||
}
|
||||
}
|
||||
height={50}
|
||||
radiusBottomRight={-30}
|
||||
width={50}
|
||||
/>
|
||||
`;
|
||||
exports[`ReactARTComponents should generate a <Shape> with a radius property of 0 when top left radius prop is negative 1`] = `
|
||||
<Shape
|
||||
d={
|
||||
Object {
|
||||
"_pivotX": 0,
|
||||
"_pivotY": 0,
|
||||
"path": Array [
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
],
|
||||
"penDownX": 0,
|
||||
"penDownY": 0,
|
||||
"penX": 0,
|
||||
"penY": 0,
|
||||
}
|
||||
}
|
||||
height={50}
|
||||
radiusTopLeft={-25}
|
||||
width={50}
|
||||
/>
|
||||
`;
|
||||
exports[`ReactARTComponents should generate a <Shape> with a radius property of 0 when top right radius prop is negative 1`] = `
|
||||
<Shape
|
||||
d={
|
||||
Object {
|
||||
"_pivotX": 0,
|
||||
"_pivotY": 0,
|
||||
"path": Array [
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
],
|
||||
"penDownX": 0,
|
||||
"penDownY": 0,
|
||||
"penX": 0,
|
||||
"penY": 0,
|
||||
}
|
||||
}
|
||||
height={50}
|
||||
radiusTopRight={-25}
|
||||
width={50}
|
||||
/>
|
||||
`;
|
||||
exports[`ReactARTComponents should generate a <Shape> with positive height when height prop is negative 1`] = `
|
||||
<Shape
|
||||
d={
|
||||
Object {
|
||||
"_pivotX": 0,
|
||||
"_pivotY": -50,
|
||||
"path": Array [
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
],
|
||||
"penDownX": 0,
|
||||
"penDownY": -50,
|
||||
"penX": 0,
|
||||
"penY": -50,
|
||||
}
|
||||
}
|
||||
height={-50}
|
||||
width={50}
|
||||
/>
|
||||
`;
|
||||
exports[`ReactARTComponents should generate a <Shape> with positive width when width prop is negative 1`] = `
|
||||
<Shape
|
||||
d={
|
||||
Object {
|
||||
"_pivotX": -50,
|
||||
"_pivotY": 0,
|
||||
"path": Array [
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
[Function],
|
||||
],
|
||||
"penDownX": -50,
|
||||
"penDownY": 0,
|
||||
"penX": -50,
|
||||
"penY": 0,
|
||||
}
|
||||
}
|
||||
height={50}
|
||||
width={-50}
|
||||
/>
|
||||
`;
|
||||
exports[`ReactARTComponents should generate a <Shape> with props for drawing the Circle 1`] = `
|
||||
<Shape
|
||||
d={
|
||||
|
||||
Reference in New Issue
Block a user