From a43007ab1eb037ce6eda841e81fc7841ca4d248a Mon Sep 17 00:00:00 2001 From: Dan Delany Date: Mon, 18 Dec 2017 18:03:09 -0500 Subject: [PATCH] cleanup, remove old/unused code --- README.md | 1 - docs/src/App.js | 2 +- src/BarChart.js | 2 +- src/index.js | 4 +- src/util.js | 2 +- tests/jsdom/spec/BarChart.spec.js | 1 - tests/jsdom/spec/resolveObjectProps.spec.js | 134 -------- tests/jsdom/spec/resolveXYScales.spec.js | 336 ++++++++++++-------- 8 files changed, 210 insertions(+), 272 deletions(-) delete mode 100644 tests/jsdom/spec/resolveObjectProps.spec.js diff --git a/README.md b/README.md index 6380f2fd..8008cb90 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,6 @@ Charting library for React * *planned: AreaRect?, AreaCircle?* ### Higher-order components -* resolveObjectProps * resolveXYScales ### Utilities diff --git a/docs/src/App.js b/docs/src/App.js index a68b626d..8efe1bcb 100644 --- a/docs/src/App.js +++ b/docs/src/App.js @@ -9,7 +9,7 @@ import Playground from './Playground'; const lessons = [ {name: "Quick Start", path: '/quick-start', Component: Lessons.QuickStartLesson}, {name: "XY Plots", path: '/xy-plots', Component: Lessons.XYPlotsLesson}, - {name: "Getters & Accessors", path: '/getters-and-accessors', Component: Lessons.GettersAndAccessorsLesson}, + // {name: "Getters & Accessors", path: '/getters-and-accessors', Component: Lessons.GettersAndAccessorsLesson}, // {name: "Interaction", path: '/interaction', Component: Lessons.InteractionLesson}, ]; diff --git a/src/BarChart.js b/src/BarChart.js index 248f7b47..726d0d96 100644 --- a/src/BarChart.js +++ b/src/BarChart.js @@ -26,7 +26,7 @@ function makeRangeBarChartProps(barChartProps) { * where each bar represents a single independent variable value and a single dependent value, * with bars that are centered horizontally on x-value and extend from 0 to y-value, * (or centered vertically on their y-value and extend from 0 to the x-value, in the case of horizontal chart variant) - * eg. http://www.snapsurveys.com/wp-content/uploads/2012/10/bar_2d8.png + * eg. http://www.snapsu rveys.com/wp-content/uploads/2012/10/bar_2d8.png * * For other bar chart types, see RangeBarChart and AreaBarChart */ diff --git a/src/index.js b/src/index.js index f6fa1ae4..963e8348 100644 --- a/src/index.js +++ b/src/index.js @@ -37,10 +37,10 @@ export {default as YAxisTitle} from './YAxisTitle'; export {default as YGrid} from './YGrid'; export {default as YTicks} from './YTicks'; -// ### Higher-order components -export {default as resolveObjectProps} from './utils/resolveObjectProps'; +// Higher-order components export {default as resolveXYScales} from './utils/resolveXYScales'; +// Containers export {default as ZoomContainer} from './ZoomContainer'; import * as Data from './utils/Data'; diff --git a/src/util.js b/src/util.js index cd4b275d..374591ca 100644 --- a/src/util.js +++ b/src/util.js @@ -12,7 +12,7 @@ export function hasOneOfTwo(a, b) { } function componentName(Component) { - return Component.displayName || "Component wrapped by resolveObjectProps"; + return Component.displayName || "Component"; } function hasSome(obj, keys) { diff --git a/tests/jsdom/spec/BarChart.spec.js b/tests/jsdom/spec/BarChart.spec.js index bde60ed6..292c610b 100644 --- a/tests/jsdom/spec/BarChart.spec.js +++ b/tests/jsdom/spec/BarChart.spec.js @@ -70,7 +70,6 @@ describe('BarChart', () => { ([0, 1, 2]).forEach((i) => { const barProps = bars.at(i).props(); - console.log(_.pick(barProps, ['x','y','width','height'])); expect(barProps.x).to.equal(xScale(xTestValues[i]) - (props.barThickness / 2)); expect(barProps.width).to.equal(props.barThickness); const yZero = yScale(0); diff --git a/tests/jsdom/spec/resolveObjectProps.spec.js b/tests/jsdom/spec/resolveObjectProps.spec.js deleted file mode 100644 index 826b2bbb..00000000 --- a/tests/jsdom/spec/resolveObjectProps.spec.js +++ /dev/null @@ -1,134 +0,0 @@ -import _ from 'lodash'; -import React from 'react'; -import {expect} from 'chai'; -import {mount, shallow} from 'enzyme'; - -import resolveObjectProps from '../../../src/utils/resolveObjectProps'; - -describe('resolveObjectProps', () => { - class XYPropTest extends React.Component { - static defaultProps = { - domain: {x: [0, 100], y: [42, 1987]}, - axisType: {x: "foo", y: "bar"}, - foo: "baz" - }; - - render() { - return
; - } - } - - const XYResolved = resolveObjectProps(XYPropTest, ['domain', 'axisType'], ['x', 'y']); - - it('resolves incompletely-specified object props into fully-specified objects using defaultProps', () => { - const props = { - domain: {x: [53, 442]}, - axisType: {y: "mimsy"} - }; - const resolved = mount().find(XYPropTest); - - expect(resolved.props().domain.y).to.equal(XYPropTest.defaultProps.domain.y); - expect(resolved.props().axisType.x).to.equal(XYPropTest.defaultProps.axisType.x); - expect(resolved.props().domain.x).to.equal(props.domain.x); - expect(resolved.props().axisType.y).to.equal(props.axisType.y); - }); - - it('resolves single values into fully-specified objects', () => { - const props = { - domain: 0, - axisType: "uffish" - }; - const resolved = mount().find(XYPropTest); - - _.forEach(props, (value, key) => { - expect(resolved.props()[key]).to.deep.equal({x: value, y: value}); - }); - }); - - it('uses defaultProps normally for undefined object props', () => { - const wrapped = mount(); - const resolved = wrapped.find(XYPropTest); - const {defaultProps} = XYPropTest; - - _.keys(defaultProps).forEach(k => { - expect(resolved.props()[k]).to.equal(defaultProps[k]); - expect(resolved.props()[k]).to.deep.equal(defaultProps[k]); - }); - }); - - it('passes fully-specified object props through', () => { - const props = { - domain: {x: [99, 199], y: [88, 188]}, - axisType: {x: "brillig", y: "slithy"} - }; - const wrapped = mount(); - const resolved = wrapped.find(XYPropTest); - - _.keys(props).forEach(k => { - expect(resolved.props()[k]).to.equal(props[k]); - expect(resolved.props()[k]).to.deep.equal(props[k]); - }); - }); - - it('passes other props through', () => { - const props = { - num: 500, - str: 'vorpal', - arr: [1, 4], - obj: {a: 5}, - nullable: null, - notDefined: undefined - }; - const wrapped = mount(); - const resolved = wrapped.find(XYPropTest); - - _.keys(props).forEach(k => { - expect(resolved.props()[k]).to.equal(props[k]) - }); - }); - - it('throws if a defaultProp is incorrectly shaped', () => { - const XYResolvedBad = resolveObjectProps(XYPropTest, ['domain', 'axisType', 'foo'], ['x', 'y']); - expect(() => { - mount(); - }).to.throw(Error); - }); -}); - -/* -todo test shouldComponentUpdate - - class TestComponent extends React.Component { - render() { - return
-
domain.x: {_.get(this.props, 'domain.x').join()}
-
domain.y: {_.get(this.props, 'domain.y').join()}
-
- } - } - const ResolvedTestComponent = resolveObjectProps(TestComponent, ['domain'], ['x', 'y']); - - class ObjectPropsShouldUpdateTest extends React.Component { - static makeDomain = () => ({domain: {x: [_.random(10), _.random(10)], y: [_.random(10), _.random(10)]}}); - state = ObjectPropsShouldUpdateTest.makeDomain(); - - onClickChange = () => { - this.setState(ObjectPropsShouldUpdateTest.makeDomain()); - } - onClickShallow = () => { - this.setState({domain: {x: this.state.domain.x, y: this.state.domain.y}}); - } - render() { - return
-
-
-
-
- -
-
-
- } - } - - */ \ No newline at end of file diff --git a/tests/jsdom/spec/resolveXYScales.spec.js b/tests/jsdom/spec/resolveXYScales.spec.js index fb931406..ac7f682e 100644 --- a/tests/jsdom/spec/resolveXYScales.spec.js +++ b/tests/jsdom/spec/resolveXYScales.spec.js @@ -1,14 +1,13 @@ -import _ from 'lodash'; -import React from 'react'; -import * as d3 from 'd3'; -import {expect} from 'chai'; -import {mount, shallow} from 'enzyme'; +import _ from "lodash"; +import React from "react"; +import * as d3 from "d3"; +import {expect} from "chai"; +import {mount, shallow} from "enzyme"; -import {isValidScale} from '../../../src/utils/Scale'; -import {innerRangeX, innerRangeY} from '../../../src/utils/Margin'; +import {isValidScale} from "../../../src/utils/Scale"; +import {innerRangeX, innerRangeY} from "../../../src/utils/Margin"; -import resolveXYScales from '../../../src/utils/resolveXYScales'; -import resolveObjectProps from '../../../src/utils/resolveObjectProps'; +import resolveXYScales from "../../../src/utils/resolveXYScales"; class NotImplementedError extends Error { constructor(message = "Not Implemented Yet") { @@ -22,8 +21,8 @@ function expectRefAndDeepEqual(a, b) { } function expectXYScales(scales) { - expect(scales).to.be.an('object'); - ['x', 'y'].forEach(k => { + expect(scales).to.be.an("object"); + ["x", "y"].forEach(k => { expect(scales).to.have.property(k); expect(isValidScale(scales[k])).to.equal(true); }); @@ -34,25 +33,29 @@ function expectXYScaledComponent(rendered, {width, height, scaleType, domain, ma // that match the expected domain, range & margin // if range not provided, it should be width/height minus margins range = range || {x: innerRangeX(width, margin), y: innerRangeY(height, margin)}; - expect(scaleType).to.be.an('object'); - console.log('expected domains', domain); - console.log('expected range', range); + expect(scaleType).to.be.an("object"); + console.log("expected domains", domain); + console.log("expected range", range); - expect(rendered.props).to.be.an('object'); + expect(rendered.props).to.be.an("object"); expect(rendered.props.margin).to.deep.equal(margin); const renderedScale = rendered.props.scale; expectXYScales(renderedScale); - ['x', 'y'].forEach(k => { + ["x", "y"].forEach(k => { expect(rendered.props.scaleType[k]).to.equal(scaleType[k]); - console.log('domain', renderedScale[k].domain()); - console.log('expected domain', domain[k]); + console.log("domain", renderedScale[k].domain()); + console.log("expected domain", domain[k]); expect(renderedScale[k].domain()).to.deep.equal(domain[k]); - if(scaleType[k] === 'ordinal') - expect(renderedScale[k].range()).to.deep - .equal(d3.scaleOrdinal().domain(domain[k]).rangePoints(range[k]).range()); - else - expect(renderedScale[k].range()).to.deep.equal(range[k]); + if (scaleType[k] === "ordinal") + expect(renderedScale[k].range()).to.deep.equal( + d3 + .scaleOrdinal() + .domain(domain[k]) + .rangePoints(range[k]) + .range() + ); + else expect(renderedScale[k].range()).to.deep.equal(range[k]); }); } @@ -61,28 +64,32 @@ function expectXYScaledComponentEnzyme(rendered, {width, height, scaleType, doma // that match the expected domain, range & margin // if range not provided, it should be width/height minus margins range = range || {x: innerRangeX(width, margin), y: innerRangeY(height, margin)}; - expect(scaleType).to.be.an('object'); + expect(scaleType).to.be.an("object"); expect(rendered.props().margin).to.deep.equal(margin); - console.log('renderedprops', rendered.props()); + console.log("renderedprops", rendered.props()); const renderedScale = rendered.props().scale; expectXYScales(renderedScale); - ['x', 'y'].forEach(k => { + ["x", "y"].forEach(k => { expect(rendered.props().scaleType[k]).to.equal(scaleType[k]); - console.log('domain', renderedScale[k].domain()); - console.log('expected domain', domain[k]); + console.log("domain", renderedScale[k].domain()); + console.log("expected domain", domain[k]); expect(renderedScale[k].domain()).to.deep.equal(domain[k]); - if(scaleType[k] === 'ordinal') - expect(renderedScale[k].range()).to.deep - .equal(d3.scaleOrdinal().domain(domain[k]).rangePoints(range[k]).range()); - else - expect(renderedScale[k].range()).to.deep.equal(range[k]); + if (scaleType[k] === "ordinal") + expect(renderedScale[k].range()).to.deep.equal( + d3 + .scaleOrdinal() + .domain(domain[k]) + .rangePoints(range[k]) + .range() + ); + else expect(renderedScale[k].range()).to.deep.equal(range[k]); }); } -describe('resolveXYScales', () => { - const customScaleType = {xScaleType: 'ordinal', yScaleType: 'linear'}; +describe("resolveXYScales", () => { + const customScaleType = {xScaleType: "ordinal", yScaleType: "linear"}; const customDomain = {xDomain: [-5, 5], yDomain: [0, 10]}; const customMargin = {marginTop: 10, marginBottom: 20, marginLeft: 30, marginRight: 40}; const width = 500; @@ -101,26 +108,56 @@ describe('resolveXYScales', () => { class ChartWithCustomScaleType extends ComponentWithChildren { static getScaleType(props) { - console.log('called getScaleType', customScaleType); - return customScaleType; } + return customScaleType; + } } const XYChartWithCustomScaleType = resolveXYScales(ChartWithCustomScaleType); class ChartWithCustomDomain extends ComponentWithChildren { - static getDomain(props) { return customDomain; } + static getDomain(props) { + return customDomain; + } } const XYChartWithCustomDomain = resolveXYScales(ChartWithCustomDomain); class ChartWithCustomMargin extends ComponentWithChildren { - static getMargin(props) { return customMargin; } + static getMargin(props) { + return customMargin; + } } const XYChartWithCustomMargin = resolveXYScales(ChartWithCustomMargin); class ContainerChart extends React.Component { render() { - const {width, height, xScale, yScale, xScaleType, yScaleType, marginTop, marginBottom, marginLeft, marginRight, xDomain, yDomain} = this.props; + const { + width, + height, + xScale, + yScale, + xScaleType, + yScaleType, + marginTop, + marginBottom, + marginLeft, + marginRight, + xDomain, + yDomain + } = this.props; const newChildren = React.Children.map(this.props.children, (child, i) => { - return React.cloneElement(child, {width, height, xScale, yScale, xScaleType, yScaleType, marginTop, marginBottom, marginLeft, marginRight, xDomain, yDomain}); + return React.cloneElement(child, { + width, + height, + xScale, + yScale, + xScaleType, + yScaleType, + marginTop, + marginBottom, + marginLeft, + marginRight, + xDomain, + yDomain + }); }); return
{newChildren}
; } @@ -137,10 +174,16 @@ describe('resolveXYScales', () => { // ['domain', 'scale', 'scaleType'], ['x', 'y'] // ); - it('passes XY scales and margins through if both are provided', () => { + it("passes XY scales and margins through if both are provided", () => { const props = { - xScale: d3.scaleLinear().domain([-1, 1]).range([0, 400]), - yScale: d3.scaleLinear().domain([-2, 2]).range([10, 300]), + xScale: d3 + .scaleLinear() + .domain([-1, 1]) + .range([0, 400]), + yScale: d3 + .scaleLinear() + .domain([-2, 2]) + .range([10, 300]), marginTop: 11, marginBottom: 21, marginLeft: 31, @@ -149,16 +192,17 @@ describe('resolveXYScales', () => { const wrapped = mount(); const rendered = wrapped.find(Chart); - ['xScale', 'yScale', 'marginTop', 'marginBottom', 'marginLeft', 'marginRight'].forEach(propKey => { + ["xScale", "yScale", "marginTop", "marginBottom", "marginLeft", "marginRight"].forEach(propKey => { expectRefAndDeepEqual(rendered.props()[propKey], props[propKey]); - }) + }); }); - it('creates scales from scaleType, size, domain & margins', () => { + it("creates scales from scaleType, size, domain & margins", () => { const props = { - width, height, - xScaleType: 'linear', - yScaleType: 'ordinal', + width, + height, + xScaleType: "linear", + yScaleType: "ordinal", xDomain: [-50, 50], yDomain: [-100, 100], marginTop: 11, @@ -173,7 +217,6 @@ describe('resolveXYScales', () => { const renderedYScale = rendered.props().yScale; // expectXYScales(renderedScale); - console.log('rendered scale ranges', renderedXScale.range(), renderedYScale.range()); expect(isValidScale(renderedXScale)).to.equal(true); expect(isValidScale(renderedYScale)).to.equal(true); expect(renderedXScale.domain()).to.deep.equal(props.xDomain); @@ -182,11 +225,12 @@ describe('resolveXYScales', () => { expect(renderedYScale.range()).to.deep.equal([height - (props.marginTop + props.marginBottom), 0]); }); - - it('infers scaleType from Component.getScaleType', () => { + it("infers scaleType from Component.getScaleType", () => { const props = { - width, height, - xDomain: [-50, 50], yDomain: [-100, 100], + width, + height, + xDomain: [-50, 50], + yDomain: [-100, 100], marginTop: 11, marginBottom: 22, marginLeft: 33, @@ -198,17 +242,17 @@ describe('resolveXYScales', () => { expect(rendered.props().xScaleType).to.equal(customScaleType.xScaleType); expect(rendered.props().yScaleType).to.equal(customScaleType.yScaleType); - }); - it('infers scaleType from data', () => { + it("infers scaleType from data", () => { const props = { - width, height, - data: [[12, 'a'], [18, 'b'], [22, 'c']], + width, + height, + data: [[12, "a"], [18, "b"], [22, "c"]], x: d => d[0], y: d => d[1], xDomain: [12, 22], - yDomain: ['a', 'b', 'c'], + yDomain: ["a", "b", "c"], marginTop: 11, marginBottom: 22, marginLeft: 33, @@ -218,8 +262,8 @@ describe('resolveXYScales', () => { const wrapped = mount(); const rendered = wrapped.find(Chart); - expect(rendered.props().xScaleType).to.equal('linear'); - expect(rendered.props().yScaleType).to.deep.equal('ordinal'); + expect(rendered.props().xScaleType).to.equal("linear"); + expect(rendered.props().yScaleType).to.deep.equal("ordinal"); }); // todo: fix this (only matters in edge case) @@ -238,36 +282,41 @@ describe('resolveXYScales', () => { // expect(rendered.props().scaleType).to.deep.equal(customScaleType); // }); - it('infers scaleType from children data', () => { + it("infers scaleType from children data", () => { const props = { - width, height, + width, + height, xDomain: [12, 22], - yDomain: ['a', 'b', 'c'], + yDomain: ["a", "b", "c"], marginTop: 11, marginBottom: 22, marginLeft: 33, marginRight: 44 }; const chartProps = { - data: [[12, 'a'], [18, 'b'], [22, 'c']], + data: [[12, "a"], [18, "b"], [22, "c"]], x: d => d[0], y: d => d[1] }; - const tree = ; + const tree = ( + + + + ); const wrapped = mount(tree); const rendered = wrapped.find(ContainerChart); - expect(rendered.props().xScaleType).to.equal('linear'); - expect(rendered.props().yScaleType).to.deep.equal('ordinal'); + expect(rendered.props().xScaleType).to.equal("linear"); + expect(rendered.props().yScaleType).to.deep.equal("ordinal"); }); - - it('infers domain from Component.getDomain', () => { + it("infers domain from Component.getDomain", () => { const props = { - width, height, - xScaleType: 'linear', - yScaleType: 'linear', + width, + height, + xScaleType: "linear", + yScaleType: "linear", marginTop: 11, marginBottom: 22, marginLeft: 33, @@ -280,14 +329,15 @@ describe('resolveXYScales', () => { expect(rendered.props().yDomain).to.deep.equal(customDomain.yDomain); }); - it('infers domain from data', () => { + it("infers domain from data", () => { const props = { - width, height, - data: [[12, 'a'], [18, 'b'], [22, 'c']], + width, + height, + data: [[12, "a"], [18, "b"], [22, "c"]], x: d => d[0], y: d => d[1], - xScaleType: 'linear', - yScaleType: 'ordinal', + xScaleType: "linear", + yScaleType: "ordinal", marginTop: 11, marginBottom: 22, marginLeft: 33, @@ -297,36 +347,48 @@ describe('resolveXYScales', () => { const rendered = wrapped.find(Chart); expect(rendered.props().xDomain).to.deep.equal([12, 22]); - expect(rendered.props().yDomain).to.deep.equal(['a', 'b', 'c']); + expect(rendered.props().yDomain).to.deep.equal(["a", "b", "c"]); }); - it('infers domain from children getDomain', () => { + it("infers domain from children getDomain", () => { const props = { - width, height, - xScaleType: 'linear', - yScaleType: 'linear', - marginTop: 11, marginBottom: 22, - marginLeft: 33, marginRight: 44 + width, + height, + xScaleType: "linear", + yScaleType: "linear", + marginTop: 11, + marginBottom: 22, + marginLeft: 33, + marginRight: 44 }; - const tree = ; + const tree = ( + + + + ); const wrapped = mount(tree); const rendered = wrapped.find(ContainerChart); expect(rendered.props().xDomain).to.deep.equal(customDomain.xDomain); expect(rendered.props().yDomain).to.deep.equal(customDomain.yDomain); }); - it('infers domain from children data', () => { + it("infers domain from children data", () => { const props = { - width, height, - xScaleType: 'linear', - yScaleType: 'linear', - marginTop: 11, marginBottom: 22, - marginLeft: 33, marginRight: 44 + width, + height, + xScaleType: "linear", + yScaleType: "linear", + marginTop: 11, + marginBottom: 22, + marginLeft: 33, + marginRight: 44 }; - const tree = - d[0]} y={d => d[1]} /> - d[0]} y={d => d[1]} /> - ; + const tree = ( + + d[0]} y={d => d[1]} /> + d[0]} y={d => d[1]} /> + + ); const wrapped = mount(tree); const rendered = wrapped.find(ContainerChart); @@ -334,12 +396,12 @@ describe('resolveXYScales', () => { expect(rendered.props().yDomain).to.deep.equal([0, 5]); }); - - it('infers margin from Component.getMargin', () => { + it("infers margin from Component.getMargin", () => { const props = { - width, height, - xScaleType: 'linear', - yScaleType: 'linear', + width, + height, + xScaleType: "linear", + yScaleType: "linear", xDomain: [-50, 50], yDomain: [-100, 100] }; @@ -351,15 +413,20 @@ describe('resolveXYScales', () => { expect(rendered.props().marginRight).to.equal(customMargin.marginRight); }); - it('infers margin from children getMargin', () => { + it("infers margin from children getMargin", () => { const props = { - width, height, - xScaleType: 'linear', - yScaleType: 'linear', + width, + height, + xScaleType: "linear", + yScaleType: "linear", xDomain: [-50, 50], yDomain: [-100, 100] }; - const tree = ; + const tree = ( + + + + ); const wrapped = mount(tree); const rendered = wrapped.find(ContainerChart); expect(rendered.props().marginTop).to.equal(customMargin.marginTop); @@ -368,18 +435,21 @@ describe('resolveXYScales', () => { expect(rendered.props().marginRight).to.equal(customMargin.marginRight); }); - it('infers margin from children margin props', () => { + it("infers margin from children margin props", () => { const props = { - width, height, - xScaleType: 'linear', - yScaleType: 'linear', + width, + height, + xScaleType: "linear", + yScaleType: "linear", xDomain: [-50, 50], yDomain: [-100, 100] }; - const tree = - - - ; + const tree = ( + + + + + ); const wrapped = mount(tree); const rendered = wrapped.find(ContainerChart); expect(rendered.props().marginTop).to.equal(20); @@ -388,17 +458,18 @@ describe('resolveXYScales', () => { expect(rendered.props().marginRight).to.equal(50); }); - - it('infers scaleType & domain from data, margin from getMargin', () => { + it("infers scaleType & domain from data, margin from getMargin", () => { const containerProps = {width, height}; const chartProps = { - data: [[12, 'a'], [18, 'b'], [22, 'c']], + data: [[12, "a"], [18, "b"], [22, "c"]], x: d => d[0], y: d => d[1] }; - const tree = - - ; + const tree = ( + + + + ); const wrapped = mount(tree); const rendered = wrapped.find(ChartWithCustomMargin); @@ -406,10 +477,10 @@ describe('resolveXYScales', () => { expect(rendered.props().marginBottom).to.equal(customMargin.marginBottom); expect(rendered.props().marginLeft).to.equal(customMargin.marginLeft); expect(rendered.props().marginRight).to.equal(customMargin.marginRight); - expect(rendered.props().xScaleType).to.equal('linear'); - expect(rendered.props().yScaleType).to.equal('ordinal'); + expect(rendered.props().xScaleType).to.equal("linear"); + expect(rendered.props().yScaleType).to.equal("ordinal"); expect(rendered.props().xDomain).to.deep.equal([12, 22]); - expect(rendered.props().yDomain).to.deep.equal(['a', 'b', 'c']); + expect(rendered.props().yDomain).to.deep.equal(["a", "b", "c"]); }); // it('works with resolveObjectProps', () => { @@ -430,15 +501,18 @@ describe('resolveXYScales', () => { // expect(rendered.props().domain.y).to.deep.equal([-12, 12]); // }); - it('inverts the scale domain if `invertScale` option is true', () => { + it("inverts the scale domain if `invertScale` option is true", () => { const props = { - width, height, + width, + height, xDomain: [-3, 3], yDomain: [0, 10], - xScaleType: 'linear', - yScaleType: 'linear', - marginTop: 11, marginBottom: 22, - marginLeft: 33, marginRight: 44 + xScaleType: "linear", + yScaleType: "linear", + marginTop: 11, + marginBottom: 22, + marginLeft: 33, + marginRight: 44 }; const invertXChart = mount().find(Chart); @@ -449,7 +523,7 @@ describe('resolveXYScales', () => { expect(invertYChart.props().xDomain).to.deep.equal([-3, 3]); expect(invertYChart.props().yDomain).to.deep.equal([10, 0]); }); - + // todo test resolving scaleType from domains // todo spacing/padding