From 928cce392fb5936b096538714c6c44e8ed04eeaa Mon Sep 17 00:00:00 2001 From: Biki-das Date: Thu, 27 Jan 2022 11:22:24 +0530 Subject: [PATCH] Added unit Tests in the ReactART, increasing the code coverage --- .../react-art/src/__tests__/ReactART-test.js | 54 ++++++ .../__snapshots__/ReactART-test.js.snap | 169 ++++++++++++++++++ 2 files changed, 223 insertions(+) diff --git a/packages/react-art/src/__tests__/ReactART-test.js b/packages/react-art/src/__tests__/ReactART-test.js index 950ec77bb1a6e..bbe6f0643d02c 100644 --- a/packages/react-art/src/__tests__/ReactART-test.js +++ b/packages/react-art/src/__tests__/ReactART-test.js @@ -440,6 +440,60 @@ describe('ReactARTComponents', () => { expect(rectangle.toJSON()).toMatchSnapshot(); }); + it('should generate a with positive width when width prop is negative', () => { + const rectangle = ReactTestRenderer.create( + , + ); + expect(rectangle.toJSON()).toMatchSnapshot(); + }); + + it('should generate a with positive height when height prop is negative', () => { + const rectangle = ReactTestRenderer.create( + , + ); + expect(rectangle.toJSON()).toMatchSnapshot(); + }); + + it('should generate a with a radius property of 0 when top left radius prop is negative', () => { + const rectangle = ReactTestRenderer.create( + , + ); + expect(rectangle.toJSON()).toMatchSnapshot(); + }); + + it('should generate a with a radius property of 0 when top right radius prop is negative', () => { + const rectangle = ReactTestRenderer.create( + , + ); + expect(rectangle.toJSON()).toMatchSnapshot(); + }); + + it('should generate a with a radius property of 0 when bottom right radius prop is negative', () => { + const rectangle = ReactTestRenderer.create( + , + ); + expect(rectangle.toJSON()).toMatchSnapshot(); + }); + + it('should generate a with a radius property of 0 when bottom left radius prop is negative', () => { + const rectangle = ReactTestRenderer.create( + , + ); + expect(rectangle.toJSON()).toMatchSnapshot(); + }); + + it('should generate a where top radius is 0 if the sum of the top radius is greater than width', () => { + const rectangle = ReactTestRenderer.create( + , + ); + expect(rectangle.toJSON()).toMatchSnapshot(); + }); + it('should warn if width/height is missing on a Rectangle component', () => { expect(() => ReactTestRenderer.create(), diff --git a/packages/react-art/src/__tests__/__snapshots__/ReactART-test.js.snap b/packages/react-art/src/__tests__/__snapshots__/ReactART-test.js.snap index 2cd1229069530..c8c5609ad922c 100644 --- a/packages/react-art/src/__tests__/__snapshots__/ReactART-test.js.snap +++ b/packages/react-art/src/__tests__/__snapshots__/ReactART-test.js.snap @@ -1,5 +1,174 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`ReactARTComponents should generate a where top radius is 0 if the sum of the top radius is greater than width 1`] = ` + +`; +exports[`ReactARTComponents should generate a with a radius property of 0 when bottom left radius prop is negative 1`] = ` + +`; +exports[`ReactARTComponents should generate a with a radius property of 0 when bottom right radius prop is negative 1`] = ` + +`; +exports[`ReactARTComponents should generate a with a radius property of 0 when top left radius prop is negative 1`] = ` + +`; +exports[`ReactARTComponents should generate a with a radius property of 0 when top right radius prop is negative 1`] = ` + +`; +exports[`ReactARTComponents should generate a with positive height when height prop is negative 1`] = ` + +`; +exports[`ReactARTComponents should generate a with positive width when width prop is negative 1`] = ` + +`; exports[`ReactARTComponents should generate a with props for drawing the Circle 1`] = `