Skip to content

Commit

Permalink
feat: Geom Label Tooltip unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
beihai.ly committed Nov 1, 2018
1 parent 7e4fb87 commit ab69f21
Show file tree
Hide file tree
Showing 6 changed files with 1,528 additions and 59 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"parser": "babel-eslint",
"root": true,
"env": {
"jest": true,
"browser": true,
"node": true,
"es6": true
Expand Down
2 changes: 2 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// general component
require('./specs/component/Chart');
require('./specs/component/Geom');
require('./specs/component/Label');
require('./specs/component/Tooltip');
61 changes: 34 additions & 27 deletions test/specs/component/Chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const BizCharts = require('../../../src/index');

chai.use(chaiEnzyme()); // Note the invocation at the end
Enzyme.configure({ adapter: new Adapter() });
const { Chart } = BizCharts;
const { Chart, Geom } = BizCharts;


describe('<Chart height={300}/>', () => {
Expand All @@ -31,30 +31,37 @@ describe('<Chart height={300} data={[{ a: 1 }]} />', () => {
});
});

// const data = [
// { year: "1991", value: 3 },
// { year: "1992", value: 4 },
// { year: "1993", value: 3.5 },
// { year: "1994", value: 5 },
// { year: "1995", value: 4.9 },
// { year: "1996", value: 6 },
// { year: "1997", value: 7 },
// { year: "1998", value: 9 },
// { year: "1999", value: 13 }
// ];

// describe('<Chart forceFit={true} />', () => {
// it('Render chart forceFit ', () => {
// const wrapper = mount(
// <div width={600}>
// <Chart height={300} width={400} data={data} >
// <Geom type="line" position="year*value" />
// </Chart>
// </div>
// );

// expect(wrapper.find('canvas').length).to.equal(1);
// expect(wrapper.find('canvas')[0].width).to.equal(600);
// });
// });
const data = [
{ year: '1991', value: 3 },
{ year: '1992', value: 4 },
{ year: '1993', value: 3.5 },
{ year: '1994', value: 5 },
{ year: '1995', value: 4.9 },
{ year: '1996', value: 6 },
{ year: '1997', value: 7 },
{ year: '1998', value: 9 },
{ year: '1999', value: 13 }
];

describe('<Chart forceFit={true} />', () => {
it('Render chart forceFit ', () => {
let g2Instance = null;
const wrapper = mount(
<div width={600} height={400} >
<Chart
onGetG2Instance={(g2Chart) => { g2Instance = g2Chart; }}
height={300}
width={400}
data={data}
forceFit
>
<Geom type="line" position="year*value" />
</Chart>
</div>
);

expect(wrapper.find('div').length).to.equal(3);
expect(g2Instance._attrs.forceFit).to.equal(true);
});
});

Loading

0 comments on commit ab69f21

Please sign in to comment.