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 11, 2020
1 parent 9c32e77 commit 4e9e122
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
6 changes: 3 additions & 3 deletions packages/vx-demo/src/sandboxes/vx-legend/Example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default function Example({ events = false }: { events?: boolean }) {
return (
<div className="legends">
<LegendDemo title="Size">
<LegendSize<number> scale={sizeScale}>
<LegendSize scale={sizeScale}>
{labels =>
labels.map(label => {
const size = sizeScale(label.datum);
Expand All @@ -96,7 +96,7 @@ export default function Example({ events = false }: { events?: boolean }) {
</LegendSize>
</LegendDemo>
<LegendDemo title="Quantile">
<LegendQuantile<string> scale={quantileScale}>
<LegendQuantile scale={quantileScale}>
{labels =>
labels.map((label, i) => (
<LegendItem
Expand Down Expand Up @@ -197,7 +197,7 @@ export default function Example({ events = false }: { events?: boolean }) {
</LegendOrdinal>
</LegendDemo>
<LegendDemo title="Custom Legend">
<Legend<string, React.FC | React.ReactNode, typeof shapeScale> scale={shapeScale}>
<Legend scale={shapeScale}>
{labels => (
<div style={{ display: 'flex', flexDirection: 'row' }}>
{labels.map((label, i) => {
Expand Down
19 changes: 5 additions & 14 deletions packages/vx-legend/test/scales.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
LegendThreshold,
LegendQuantile,
} from '../src';
import { ScaleBand, ScaleOrdinal, ScaleThreshold, ScaleQuantile } from '../src/types';

describe('Legend scales', () => {
it('should render with scaleLinear', () => {
Expand All @@ -20,7 +19,7 @@ describe('Legend scales', () => {
});

expect(() => shallow(<LegendLinear scale={linearScale} />)).not.toThrow();
expect(() => shallow(<LegendSize<number> scale={linearScale} />)).not.toThrow();
expect(() => shallow(<LegendSize scale={linearScale} />)).not.toThrow();
expect(() => shallow(<Legend scale={linearScale} />)).not.toThrow();
});

Expand All @@ -31,9 +30,7 @@ describe('Legend scales', () => {
});

expect(() => shallow(<LegendOrdinal scale={ordinalScale} />)).not.toThrow();
expect(() =>
shallow(<Legend<string, string, ScaleOrdinal<string, string>> scale={ordinalScale} />),
).not.toThrow();
expect(() => shallow(<Legend scale={ordinalScale} />)).not.toThrow();
});

it('should render with scaleBand', () => {
Expand All @@ -42,9 +39,7 @@ describe('Legend scales', () => {
range: [1, 10],
});

expect(() =>
shallow(<Legend<string, number, ScaleBand<string, number>> scale={bandScale} />),
).not.toThrow();
expect(() => shallow(<Legend scale={bandScale} />)).not.toThrow();
});

it('should render with scaleThreshold', () => {
Expand All @@ -54,9 +49,7 @@ describe('Legend scales', () => {
});

expect(() => shallow(<LegendThreshold scale={thresholdScale} />)).not.toThrow();
expect(() =>
shallow(<Legend<number, string, ScaleThreshold<number, string>> scale={thresholdScale} />),
).not.toThrow();
expect(() => shallow(<Legend scale={thresholdScale} />)).not.toThrow();
});

it('should render with scaleQuantile', () => {
Expand All @@ -66,8 +59,6 @@ describe('Legend scales', () => {
});

expect(() => shallow(<LegendQuantile scale={quantileScale} />)).not.toThrow();
expect(() =>
shallow(<Legend<number, string, ScaleQuantile<number, string>> scale={quantileScale} />),
).not.toThrow();
expect(() => shallow(<Legend scale={quantileScale} />)).not.toThrow();
});
});

0 comments on commit 4e9e122

Please sign in to comment.