Skip to content

Commit

Permalink
Merge pull request #208 from antvis/jest-for-test
Browse files Browse the repository at this point in the history
chore: 使用jest-electron替代torch & 使用TS编写单侧
  • Loading branch information
paleface001 committed Nov 12, 2019
2 parents cffdf54 + 158fe7a commit 94485f1
Show file tree
Hide file tree
Showing 52 changed files with 561 additions and 600 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
node-version: [8.x, 10.x, 12.x]
node-version: [12.x]

steps:
- uses: actions/checkout@v1
Expand All @@ -22,3 +22,7 @@ jobs:
npm run ci
env:
CI: true
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
46 changes: 0 additions & 46 deletions __tests__/data/radar.js-

This file was deleted.

File renamed without changes.
85 changes: 42 additions & 43 deletions __tests__/unit/area-spec.js → __tests__/unit/area-spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Area, StackArea } from '../../src';
import { expect } from 'chai';

const data = [
{
Expand Down Expand Up @@ -314,12 +313,12 @@ describe('Area plot', () => {
const positionField = view.get('elements')[0].get('position').fields;
const axes = view.get('axisController').axes;

expect(areaPlot).to.be.instanceOf(Area);
expect(positionField[0]).to.be.equal('year');
expect(positionField[1]).to.be.equal('value');
expect(axes.length).to.be.equal(2);
expect(areaPlot). toBeInstanceOf(Area);
expect(positionField[0]).toBe('year');
expect(positionField[1]).toBe('value');
expect(axes.length).toBe(2);
areaPlot.destroy();
expect(view.destroyed).to.be.true;
expect(view.destroyed).toBe(true);
});

it('area style', () => {
Expand Down Expand Up @@ -364,10 +363,10 @@ describe('Area plot', () => {
areaPlot.render();
const view = areaPlot.getLayer().view;
const elements = view.get('elements');
expect(elements[0].get('type')).to.be.equal('area');
expect(elements[0].get('style').cfg.strokeStyle).to.be.equal('black');
expect(elements[0].get('type')).toBe('area');
expect(elements[0].get('style').cfg.strokeStyle).toBe('black');
areaPlot.destroy();
expect(view.destroyed).to.be.true;
expect(view.destroyed).toBe(true);
});

it('line shape attr map', () => {
Expand Down Expand Up @@ -399,11 +398,11 @@ describe('Area plot', () => {
areaPlot.render();
const view = areaPlot.getLayer().view;
const elements = view.get('elements');
expect(elements[1].get('type')).to.be.equal('line');
expect(elements[1].get('size').values[0]).to.be.equal(6);
expect(elements[1].get('color').values[0]).to.be.equal('pink');
expect(elements[1].get('type')).toBe('line');
expect(elements[1].get('size').values[0]).toBe(6);
expect(elements[1].get('color').values[0]).toBe('pink');
areaPlot.destroy();
expect(view.destroyed).to.be.true;
expect(view.destroyed).toBe(true);
});

it('line style obj', () => {
Expand Down Expand Up @@ -448,11 +447,11 @@ describe('Area plot', () => {
areaPlot.render();
const view = areaPlot.getLayer().view;
const elements = view.get('elements');
expect(elements[1].get('type')).to.be.equal('line');
expect(elements[1].get('size').values[0]).to.be.equal(6);
expect(elements[1].get('style').cfg.color).to.be.equal('blue');
expect(elements[1].get('type')).toBe('line');
expect(elements[1].get('size').values[0]).toBe(6);
expect(elements[1].get('style').cfg.color).toBe('blue');
areaPlot.destroy();
expect(view.destroyed).to.be.true;
expect(view.destroyed).toBe(true);
});

// it('line style func', () => {
Expand Down Expand Up @@ -498,12 +497,12 @@ describe('Area plot', () => {
// const positionField = areaPlot.plot.get('elements')[0].get('position').fields;
// const axes = areaPlot.plot.get('axisController').axes;

// expect(areaPlot).to.be.instanceOf(Area);
// expect(positionField[0]).to.be.equal('year');
// expect(positionField[1]).to.be.equal('value');
// expect(axes.length).to.be.equal(2);
// expect(areaPlot). toBeInstanceOf(Area);
// expect(positionField[0]).toBe('year');
// expect(positionField[1]).toBe('value');
// expect(axes.length).toBe(2);
// // areaPlot.destroy();
// // expect(areaPlot.plot.destroyed).to.be.true;
// // expect(areaPlot.plot.destroyed).toBe(true);
// });

it('point shape attr map', () => {
Expand Down Expand Up @@ -543,14 +542,14 @@ describe('Area plot', () => {
areaPlot.render();
const view = areaPlot.getLayer().view;
const elements = view.get('elements');
expect(elements[1].get('type')).to.be.equal('line');
expect(elements[1].get('size').values[0]).to.be.equal(6);
expect(elements[1].get('style').cfg.strokeStyle).to.be.equal('blue');
expect(elements[2].get('type')).to.be.equal('point');
expect(elements[2].get('size').values[0]).to.be.equal(8);
expect(elements[2].get('color').values[0]).to.be.equal('yellow');
expect(elements[1].get('type')).toBe('line');
expect(elements[1].get('size').values[0]).toBe(6);
expect(elements[1].get('style').cfg.strokeStyle).toBe('blue');
expect(elements[2].get('type')).toBe('point');
expect(elements[2].get('size').values[0]).toBe(8);
expect(elements[2].get('color').values[0]).toBe('yellow');
areaPlot.destroy();
expect(view.destroyed).to.be.true;
expect(view.destroyed).toBe(true);
});

it.skip('point style obj', () => {
Expand Down Expand Up @@ -596,14 +595,14 @@ describe('Area plot', () => {
});
areaPlot.render();
const elements = areaPlot.getLayer().view.get('elements');
expect(elements[1].get('type')).to.be.equal('line');
expect(elements[1].get('size').values[0]).to.be.equal(6);
expect(elements[1].get('style').cfg.strokeStyle).to.be.equal('blue');
expect(elements[2].get('type')).to.be.equal('point');
expect(elements[2].get('size').values[0]).to.be.equal(8);
expect(elements[2].get('style').cfg.fillStyle).to.be.equal('red');
expect(elements[1].get('type')).toBe('line');
expect(elements[1].get('size').values[0]).toBe(6);
expect(elements[1].get('style').cfg.strokeStyle).toBe('blue');
expect(elements[2].get('type')).toBe('point');
expect(elements[2].get('size').values[0]).toBe(8);
expect(elements[2].get('style').cfg.fillStyle).toBe('red');
areaPlot.destroy();
expect(areaPlot.plot.destroyed).to.be.true;
expect(areaPlot.plot.destroyed).toBe(true);
});

it('area seriesField', () => {
Expand Down Expand Up @@ -651,11 +650,11 @@ describe('Area plot', () => {
areaPlot.render();
const view = areaPlot.getLayer().view;
const elements = view.get('elements');
expect(elements[0].get('type')).to.be.equal('area');
expect(elements[0].get('color').values[0]).to.be.equal('green');
expect(elements[0].get('color').fields[0]).to.be.equal('type');
expect(elements[0].get('type')).toBe('area');
expect(elements[0].get('color').values[0]).toBe('green');
expect(elements[0].get('color').fields[0]).toBe('type');
areaPlot.destroy();
expect(view.destroyed).to.be.true;
expect(view.destroyed).toBe(true);
});
});

Expand Down Expand Up @@ -685,9 +684,9 @@ describe('Area plot', () => {
const legend = plot.get('legendController').legends[0];
const area = plot.get('elements')[0];

expect(legend.get('position')).to.be.equal('top-left');
expect(legend.get('wordSpacing')).to.be.equal(4);
expect(area.get('styleOptions').cfg.opacity).to.be.equal(0.25);
expect(legend.get('position')).toBe('top-left');
expect(legend.get('wordSpacing')).toBe(4);
expect(area.get('styleOptions').cfg.opacity).toBe(0.25);
areaPlot.destroy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ describe.skip('stackArea label', () => {
// const isTransposed = areaPlot.plot.get('coord').isTransposed;
// const axes = areaPlot.plot.get('axisController').axes;

// expect(areaPlot).to.be.instanceOf(Area);
// expect(positionField[0]).to.be.equal('value');
// expect(positionField[1]).to.be.equal('year');
// expect(isTransposed).to.be.equal(false);
// expect(axes.length).to.be.equal(2);
// expect(areaPlot). toBeInstanceOf(Area);
// expect(positionField[0]).toBe('value');
// expect(positionField[1]).toBe('year');
// expect(isTransposed).toBe(false);
// expect(axes.length).toBe(2);
// areaPlot.destroy();
// expect(areaPlot.plot.destroyed).to.be.true;
// expect(areaPlot.plot.destroyed).toBe(true);
});
});
Loading

0 comments on commit 94485f1

Please sign in to comment.