Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[shape] Add tests for Arc, AreaClosed, & Line #95

Merged
merged 1 commit into from
Jul 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/vx-shape/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@
},
"devDependencies": {
"babel-jest": "^20.0.3",
"d3-array": "^1.2.0",
"enzyme": "^2.8.2",
"jest": "^20.0.3",
"react": "^15.0.0 || 15.x",
"react-addons-test-utils": "^15.5.1",
"react-fatigue-dev": "github:tj/react-fatigue-dev",
"react-tools": "^0.10.0",
"regenerator-runtime": "^0.10.5",
"react": "^15.0.0 || 15.x"
"regenerator-runtime": "^0.10.5"
},
"peerDependencies": {
"react": "^15.0.0 || 15.x"
Expand Down
2 changes: 1 addition & 1 deletion packages/vx-shape/src/shapes/AreaClosed.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function AreaClosed({
strokeDasharray,
strokeWidth = 2,
stroke = 'black',
fill = rgba(0,0,0,0.3),
fill = "rgba(0,0,0,0.3)",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch. not sure if we've thought about adding .eslint for the library but I think single quotes are preferred for strings

Copy link
Contributor Author

@Flaque Flaque Jul 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good point! Sorry about that.

Side question: Is there an beautifier for the Airbnb JS style? Also, would anyone mind if I added an .eslint and checks to the travis build?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beautifier as in an IDE plugin of sorts? I'm not totally sure about that one but harry might know.

I think adding linting to the root of the vx repo and running it for travis could be a good call for catching things like this (and shouldn't require adding it to every package). the number of errors flagged on the initial pass can be a little rough though and it will flag things like propTypes + defaultProps not being defined for components but could add them to the ignore list to start. Happy to give this a shot as well / recently set it up for the @data-ui repo.

I'd imagine @Harry has probably given this all some thought already, though?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I might beat you to it. 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I did steal your .eslintrc 😜

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ho boy.
screen shot 2017-07-13 at 8 31 59 pm

curve,
...restProps,
}) {
Expand Down
21 changes: 21 additions & 0 deletions packages/vx-shape/test/Arc.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from "react";
import { shallow } from "enzyme";
import { Arc } from "../src";
import { browserUsage } from "../../vx-mock-data";

const ArcWrapper = ({ ...restProps }) =>
shallow(<Arc data={browserUsage} {...restProps} />);

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

test("it should have the .vx-arcs-group class", () => {
expect(ArcWrapper().prop("className")).toBe("vx-arcs-group");
});

test("it should contain paths", () => {
expect(ArcWrapper().find("path").length).toBeGreaterThan(0);
});
});
47 changes: 41 additions & 6 deletions packages/vx-shape/test/AreaClosed.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,42 @@
import { AreaClosed } from '../src';
import React from "react";
import { shallow } from "enzyme";
import { extent, max } from "d3-array";
import { AreaClosed } from "../src";
import { appleStock } from "../../vx-mock-data";
import { scaleTime, scaleLinear } from "../../vx-scale";

describe('<AreaClosed />', () => {
test('it should be defined', () => {
expect(AreaClosed).toBeDefined()
})
})
const xStock = d => new Date(d.date);
const yStock = d => d.close;

const fakeXScale = scaleTime({
range: [0, 100],
domain: extent(appleStock, xStock)
});

const fakeYScale = scaleLinear({
range: [100, 0],
domain: [0, max(appleStock, yStock)],
nice: true
});

const AreaClosedWrapper = ({ ...restProps }) =>
shallow(
<AreaClosed
data={appleStock}
xScale={fakeXScale}
yScale={fakeYScale}
x={xStock}
y={yStock}
{...restProps}
/>
);

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

test("it should have the .vx-area-closed class", () => {
expect(AreaClosedWrapper().find('path').prop("className")).toBe("vx-area-closed");
});
});
24 changes: 18 additions & 6 deletions packages/vx-shape/test/Line.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import { Line } from '../src';
import React from "react";
import { shallow } from "enzyme";
import { Line } from "../src";

describe('<Line />', () => {
test('it should be defined', () => {
expect(Line).toBeDefined()
})
})
const LineWrapper = ({ ...restProps }) => shallow(<Line {...restProps} />);

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

test("it should contain a <line/>", () => {
expect(LineWrapper().find("line").length).toBe(1);
});

test("it should have the .vx-line class", () => {
expect(LineWrapper().prop("className")).toBe("vx-line");
});
});