From d2752ea912d458170fcdb181f93a5dacfc667a54 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 4 Oct 2019 13:17:51 -0700 Subject: [PATCH] fix(vx-voronoi): make polygon required to fix type --- packages/vx-voronoi/src/components/VoronoiPolygon.tsx | 6 ++---- packages/vx-voronoi/test/VoronoiPolygon.test.tsx | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/vx-voronoi/src/components/VoronoiPolygon.tsx b/packages/vx-voronoi/src/components/VoronoiPolygon.tsx index 45478a9861..253fa9b220 100644 --- a/packages/vx-voronoi/src/components/VoronoiPolygon.tsx +++ b/packages/vx-voronoi/src/components/VoronoiPolygon.tsx @@ -7,17 +7,15 @@ export type VoronoiPolygonProps = { /** className to apply to path element. */ className?: string; /** Array of coordinate arrays for the polygon (e.g., [[x,y], [x1,y1], ...]), used to generate polygon path. */ - polygon?: [number, number][]; + polygon: [number, number][]; }; export default function VoronoiPolygon({ - polygon = [], + polygon, className, children, ...restProps }: VoronoiPolygonProps & Omit, keyof VoronoiPolygonProps>) { - if (polygon.length === 0) return null; - const path = `M${polygon.join('L')}Z`; if (children) return <>{children({ path, polygon })}; diff --git a/packages/vx-voronoi/test/VoronoiPolygon.test.tsx b/packages/vx-voronoi/test/VoronoiPolygon.test.tsx index 1963cf0529..1f0b8c74fd 100644 --- a/packages/vx-voronoi/test/VoronoiPolygon.test.tsx +++ b/packages/vx-voronoi/test/VoronoiPolygon.test.tsx @@ -12,9 +12,9 @@ describe('', () => { expect(VoronoiPolygon).toBeDefined(); }); - test('it should not render without a polygon', () => { - const wrapper = shallow(); - expect(wrapper.type()).toBeNull(); + test('it should require a polygon prop', () => { + // @ts-ignore allow invalid props + expect(() => shallow()).toThrow(); }); test('it should render a path', () => {