-
Notifications
You must be signed in to change notification settings - Fork 715
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 stringsThere was a problem hiding this comment.
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?There was a problem hiding this comment.
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 likepropTypes
+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?
There was a problem hiding this comment.
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. 😅
There was a problem hiding this comment.
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 😜
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ho boy.