Skip to content

Commit

Permalink
test: 补充新 pan 方法的单测
Browse files Browse the repository at this point in the history
  • Loading branch information
edokeh committed Jun 9, 2020
1 parent 6748376 commit b5f47fa
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions test/unit/interaction/new/index-spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import data from './data.json';

const expect = require('chai').expect;
const F2 = require('../../../../src/index');

const onStartCallback = jest.fn();
Expand Down Expand Up @@ -38,17 +38,27 @@ chart.render();

describe('Interaction', () => {
it('pinch', () => {
// const interactionContext = chart.get('interactionContext');
// interactionContext.start();
// interactionContext.doZoom(0.5, 0.5, 1.5);
const interactionContext = chart.get('interactionContext');
interactionContext.start();
interactionContext.doZoom(0.5, 0.5, 1.5);

chart.get('canvas').emit('pinchstart', {});
expect(onStartCallback.mock.calls.length).toBe(1);
expect(onStartCallback.mock.calls.length).to.eql(1);
});

it('pan', () => {
const beforePoints = chart.get('canvas').get('children')[1].get('children')[0].get('children')[0].get('attrs').points;
const firstPoint = beforePoints.find(p => !isNaN(p.x));
expect(firstPoint.reportDate).to.eql('2017-03-15');
expect(firstPoint.rate).to.eql(-1.3);

const interactionContext = chart.get('interactionContext');
interactionContext.start();
interactionContext.doMove(0.1);
const afterPoints = chart.get('canvas').get('children')[1].get('children')[0].get('children')[0].get('attrs').points;
const afterPoint = afterPoints.find(p => !isNaN(p.x));
expect(afterPoint.reportDate).to.eql('2017-02-15');
expect(afterPoint.rate).to.eql(-6.9);

});
});

0 comments on commit b5f47fa

Please sign in to comment.