Skip to content

Commit

Permalink
fix(shape): default LinePath strokeLinecap to round
Browse files Browse the repository at this point in the history
  • Loading branch information
williaster committed Mar 12, 2021
1 parent 6e2d202 commit 108091f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
3 changes: 3 additions & 0 deletions packages/visx-shape/src/shapes/LinePath.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export default function LinePath<Datum>({
className={cx('visx-linepath', className)}
d={path(data) || ''}
fill={fill}
// without this a datum surrounded by nulls will not be visible
// https://github.com/d3/d3-shape#line_defined
strokeLinecap="round"
{...restProps}
/>
);
Expand Down
18 changes: 11 additions & 7 deletions packages/visx-shape/test/LinePath.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,37 @@ const LinePathChildren = ({ children, ...restProps }: Partial<LinePathProps<Datu
shallow(<LinePath {...restProps}>{children}</LinePath>);

describe('<LinePath />', () => {
test('it should be defined', () => {
it('should be defined', () => {
expect(LinePath).toBeDefined();
});

test('it should have the .visx-linepath class', () => {
it('should have the .visx-linepath class', () => {
expect(LinePathWrapper(linePathProps).prop('className')).toBe('visx-linepath');
});

test('it should contain paths', () => {
it('should default to strokeLinecap="round" for superior missing data rendering', () => {
expect(LinePathWrapper(linePathProps).prop('strokeLinecap')).toBe('round');
});

it('should contain paths', () => {
expect(LinePathWrapper(linePathProps).find('path').length).toBeGreaterThan(0);
});

test('it should take a children as function prop', () => {
it('should take a children as function prop', () => {
const fn = jest.fn();
LinePathChildren({ children: fn });
expect(fn).toHaveBeenCalled();
});

test('it should call children function with { path }', () => {
it('should call children function with { path }', () => {
const fn = jest.fn();
LinePathChildren({ children: fn });
const args = fn.mock.calls[0][0];
const keys = Object.keys(args);
expect(keys.includes('path')).toEqual(true);
expect(keys).toContain('path');
});

test('it should expose its ref via an innerRef prop', () => {
it('should expose its ref via an innerRef prop', () => {
// eslint-disable-next-line jest/no-test-return-statement
return new Promise(done => {
const refCallback = (ref: SVGPathElement) => {
Expand Down

0 comments on commit 108091f

Please sign in to comment.