Skip to content

Commit

Permalink
fix: unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kristw committed Aug 5, 2020
1 parent 3da1947 commit 82325a2
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 122 deletions.
57 changes: 0 additions & 57 deletions packages/vx-shape/src/types/bar.ts

This file was deleted.

3 changes: 2 additions & 1 deletion packages/vx-shape/test/Arc.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('<Arc />', () => {
ArcChildren({ 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 take an innerRadius number prop', () => {
Expand Down Expand Up @@ -192,6 +192,7 @@ describe('<Arc />', () => {
});

test('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) => {
expect(ref.tagName).toMatch('path');
Expand Down
3 changes: 2 additions & 1 deletion packages/vx-shape/test/Area.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('<Area />', () => {
});

test('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) => {
expect(ref.tagName).toMatch('path');
Expand All @@ -64,7 +65,7 @@ describe('<Area />', () => {
AreaChildren({ 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 take an x number prop', () => {
Expand Down
25 changes: 14 additions & 11 deletions packages/vx-shape/test/AreaClosed.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { shallow, mount } from 'enzyme';

import { scaleLinear } from '@vx/scale';
import { AreaClosed } from '../src';
import { AreaClosedProps } from '../src/shapes/AreaClosed';

Expand All @@ -15,18 +16,20 @@ const data: Datum[] = [
{ x: new Date('2017-01-03'), y: 5 },
];

const xScale = () => 50;
xScale.range = () => [0, 100];
xScale.domain = () => [0, 100];
xScale.copy = () => xScale;
const yScale = scaleLinear({ domain: [0, 100], range: [100, 0] });

const yScale = () => 50;
yScale.range = () => [100, 0] as [number, number];
yScale.domain = () => [0, 100] as [number, number];
yScale.copy = () => yScale;
// const xScale = () => 50;
// xScale.range = () => [0, 100];
// xScale.domain = () => [0, 100];
// xScale.copy = () => xScale;

const x = () => xScale();
const y = () => yScale();
// const yScale = () => 50;
// yScale.range = () => [100, 0] as [number, number];
// yScale.domain = () => [0, 100] as [number, number];
// yScale.copy = () => yScale;

const x = () => 50;
const y = () => 50;

const AreaClosedWrapper = (restProps = {}) =>
shallow(<AreaClosed data={data} yScale={yScale} x={x} y1={y} {...restProps} />);
Expand Down Expand Up @@ -72,7 +75,7 @@ describe('<AreaClosed />', () => {
AreaClosedChildren({ 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 take an x number prop', () => {
Expand Down
37 changes: 21 additions & 16 deletions packages/vx-shape/test/BarGroup.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';

import { scaleBand, scaleLinear } from '@vx/scale';
import { BarGroup } from '../src';
import { BarGroupProps } from '../src/shapes/BarGroup';
import { GroupKey } from '../src/types';
Expand Down Expand Up @@ -28,22 +29,26 @@ const data: Datum[] = [
];

const x0 = () => 5;
const x0Scale = () => 2;
x0Scale.bandwidth = () => 10;
x0Scale.domain = () => [0, 100] as [number, number];
x0Scale.range = () => [0, 100] as [number, number];
x0Scale.copy = () => x0Scale;

const x1Scale = () => 5;
x1Scale.bandwidth = () => 2;
x1Scale.domain = () => [0, 100] as [number, number];
x1Scale.range = () => [0, 100] as [number, number];
x1Scale.copy = () => x1Scale;

const yScale = () => 5;
yScale.domain = () => [0, 100] as [number, number];
yScale.range = () => [0, 100] as [number, number];
yScale.copy = () => yScale;
const x0Scale = scaleBand({ domain: [0, 100], range: [0, 100] });
const x1Scale = scaleBand({ domain: [0, 100], range: [0, 100] });
const yScale = scaleLinear({ domain: [0, 100], range: [0, 100] });

// const x0Scale = () => 2;
// x0Scale.bandwidth = () => 10;
// x0Scale.domain = () => [0, 100] as [number, number];
// x0Scale.range = () => [0, 100] as [number, number];
// x0Scale.copy = () => x0Scale;

// const x1Scale = () => 5;
// x1Scale.bandwidth = () => 2;
// x1Scale.domain = () => [0, 100] as [number, number];
// x1Scale.range = () => [0, 100] as [number, number];
// x1Scale.copy = () => x1Scale;

// const yScale = () => 5;
// yScale.domain = () => [0, 100] as [number, number];
// yScale.range = () => [0, 100] as [number, number];
// yScale.copy = () => yScale;

const color = () => 'skyblue';
const keys = ['New York', 'San Francisco', 'Austin'];
Expand Down
45 changes: 24 additions & 21 deletions packages/vx-shape/test/BarGroupHorizontal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { shallow } from 'enzyme';

import { scaleBand, scaleLinear } from '@vx/scale';
import { BarGroupHorizontal } from '../src';
import { BarGroupHorizontalProps } from '../src/shapes/BarGroupHorizontal';
import { GroupKey } from '../src/types';
import { BarGroupHorizontalProps } from '../lib/shapes/BarGroupHorizontal';

interface Datum {
date: Date;
Expand All @@ -27,21 +27,27 @@ const data: Datum[] = [
},
];

const y0 = () => 1;
const y0Scale = () => 2;
y0Scale.bandwidth = () => 10;
y0Scale.domain = () => [0, 100] as [number, number];
y0Scale.range = () => [0, 100] as [number, number];
y0Scale.copy = () => y0Scale;
const y1Scale = () => 1;
y1Scale.bandwidth = () => 2;
y1Scale.domain = () => [0, 100] as [number, number];
y1Scale.range = () => [0, 100] as [number, number];
y1Scale.copy = () => y1Scale;
const xScale = (d: Datum) => 5;
xScale.domain = () => [0, 100] as [number, number];
xScale.range = () => [0, 100] as [number, number];
xScale.copy = () => xScale;
const y0 = () => 5;
const y0Scale = scaleBand({ domain: [0, 100], range: [0, 100] });
const y1Scale = scaleBand({ domain: [0, 100], range: [0, 100] });
const xScale = scaleLinear({ domain: [0, 100], range: [0, 100] });

// const y0 = () => 1;
// const y0Scale = () => 2;
// y0Scale.bandwidth = () => 10;
// y0Scale.domain = () => [0, 100] as [number, number];
// y0Scale.range = () => [0, 100] as [number, number];
// y0Scale.copy = () => y0Scale;
// const y1Scale = () => 1;
// y1Scale.bandwidth = () => 2;
// y1Scale.domain = () => [0, 100] as [number, number];
// y1Scale.range = () => [0, 100] as [number, number];
// y1Scale.copy = () => y1Scale;
// const xScale = (d: Datum) => 5;
// xScale.domain = () => [0, 100] as [number, number];
// xScale.range = () => [0, 100] as [number, number];
// xScale.copy = () => xScale;

const color = () => 'violet';
const keys = ['New York', 'San Francisco', 'Austin'];
const width = 1;
Expand All @@ -61,10 +67,7 @@ const BarGroupWrapper = (restProps = {}) =>
/>,
);

const BarGroupChildren = ({
children,
...restProps
}: Partial<BarGroupHorizontalProps<Datum, GroupKey>>) =>
const BarGroupChildren = ({ children, ...restProps }: Partial<BarGroupHorizontalProps<Datum>>) =>
shallow(
<BarGroupHorizontal
data={data}
Expand Down
19 changes: 12 additions & 7 deletions packages/vx-shape/test/BarStack.test.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import React from 'react';
import { shallow } from 'enzyme';

import { scaleBand } from '@vx/scale';
import { BarStack } from '../src';

const scale = () => 2;
scale.domain = () => [0, 100] as [number, number];
scale.range = () => [0, 100] as [number, number];
scale.bandwidth = () => 2;
scale.step = () => 2;
scale.copy = () => scale;
const scale = scaleBand({
domain: [0, 100],
range: [0, 100],
});

// const scale = () => 2;
// scale.domain = () => [0, 100] as [number, number];
// scale.range = () => [0, 100] as [number, number];
// scale.bandwidth = () => 2;
// scale.step = () => 2;
// scale.copy = () => scale;

describe('<BarStack />', () => {
test('it should be defined', () => {
Expand Down
24 changes: 16 additions & 8 deletions packages/vx-shape/test/BarStackHorizontal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import React from 'react';
import { shallow } from 'enzyme';

import { scaleBand } from '@vx/scale';
import { BarStackHorizontal } from '../src';

const scale = () => 5;
scale.domain = () => [0, 100] as [number, number];
scale.range = () => [0, 100] as [number, number];
scale.bandwidth = () => 5;
scale.step = () => 5;
scale.paddingInner = () => 5;
scale.paddingOuter = () => 5;
scale.copy = () => scale;
const scale = scaleBand({
domain: [0, 100],
range: [0, 100],
paddingInner: 5,
paddingOuter: 5,
});

// const scale = () => 5;
// scale.domain = () => [0, 100] as [number, number];
// scale.range = () => [0, 100] as [number, number];
// scale.bandwidth = () => 5;
// scale.step = () => 5;
// scale.paddingInner = () => 5;
// scale.paddingOuter = () => 5;
// scale.copy = () => scale;

describe('<BarStackHorizontal />', () => {
test('it should be defined', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/vx-shape/test/Circle.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('<Circle />', () => {
});

test('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: SVGCircleElement) => {
expect(ref.tagName).toMatch('circle');
Expand Down
1 change: 1 addition & 0 deletions packages/vx-shape/test/Line.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('<Line />', () => {
});

test('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: SVGLineElement) => {
expect(ref.tagName).toMatch('line');
Expand Down
1 change: 1 addition & 0 deletions packages/vx-shape/test/LinkHorizontal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('<LinkHorizontal />', () => {
});

test('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) => {
expect(ref.tagName).toMatch('path');
Expand Down
1 change: 1 addition & 0 deletions packages/vx-shape/test/LinkVertical.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('<LinkVertical />', () => {
});

test('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) => {
expect(ref.tagName).toMatch('path');
Expand Down

0 comments on commit 82325a2

Please sign in to comment.