Skip to content

Commit

Permalink
fix(vx-voronoi): make polygon required to fix type
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Williams committed Oct 4, 2019
1 parent c70156c commit d2752ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions packages/vx-voronoi/src/components/VoronoiPolygon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<React.SVGProps<SVGPathElement>, keyof VoronoiPolygonProps>) {
if (polygon.length === 0) return null;

const path = `M${polygon.join('L')}Z`;
if (children) return <>{children({ path, polygon })}</>;

Expand Down
6 changes: 3 additions & 3 deletions packages/vx-voronoi/test/VoronoiPolygon.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ describe('<VoronoiPolygon />', () => {
expect(VoronoiPolygon).toBeDefined();
});

test('it should not render without a polygon', () => {
const wrapper = shallow(<VoronoiPolygon />);
expect(wrapper.type()).toBeNull();
test('it should require a polygon prop', () => {
// @ts-ignore allow invalid props
expect(() => shallow(<VoronoiPolygon />)).toThrow();
});

test('it should render a path', () => {
Expand Down

0 comments on commit d2752ea

Please sign in to comment.