Skip to content

Commit

Permalink
test: 修改 brush 单测
Browse files Browse the repository at this point in the history
  • Loading branch information
visiky committed Jul 23, 2021
1 parent ff84f98 commit ae4b2f4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
15 changes: 11 additions & 4 deletions __tests__/unit/plots/bar/interaction-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,27 @@ describe('bar interaction', () => {
});
expect(plot.chart.interactions['brush']).toBeDefined();

plot.update({ brush: { type: 'x' } });
plot.update({ brush: { type: 'circle' } });
expect(plot.chart.interactions['brush']).toBeDefined();

plot.update({ brush: { type: 'x-rect' } });
// 不同 brush 是互斥的
expect(plot.chart.interactions['brush']).not.toBeDefined();
expect(plot.chart.interactions['brush-x']).toBeDefined();

plot.update({ brush: { type: 'y' } });
plot.update({ brush: { type: 'path' } });
expect(plot.chart.interactions['brush-x']).not.toBeDefined();
expect(plot.chart.interactions['brush']).toBeDefined();

plot.update({ brush: { type: 'y-rect' } });
expect(plot.chart.interactions['brush-x']).not.toBeDefined();
expect(plot.chart.interactions['brush-y']).toBeDefined();

plot.update({ brush: { type: 'y', action: 'highlight' } });
plot.update({ brush: { type: 'y-rect', action: 'highlight' } });
expect(plot.chart.interactions['brush-y']).not.toBeDefined();
expect(plot.chart.interactions['brush-y-highlight']).toBeDefined();

plot.update({ brush: { type: 'x', action: 'highlight' } });
plot.update({ brush: { type: 'x-rect', action: 'highlight' } });
expect(plot.chart.interactions['brush-x']).not.toBeDefined();
expect(plot.chart.interactions['brush-y-highlight']).not.toBeDefined();
expect(plot.chart.interactions['brush-x-highlight']).toBeDefined();
Expand Down
15 changes: 11 additions & 4 deletions __tests__/unit/plots/column/interaction-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,27 @@ describe('column interaction', () => {
});
expect(plot.chart.interactions['brush']).toBeDefined();

plot.update({ brush: { type: 'x' } });
plot.update({ brush: { type: 'circle' } });
expect(plot.chart.interactions['brush']).toBeDefined();

plot.update({ brush: { type: 'x-rect' } });
// 不同 brush 是互斥的
expect(plot.chart.interactions['brush']).not.toBeDefined();
expect(plot.chart.interactions['brush-x']).toBeDefined();

plot.update({ brush: { type: 'y' } });
plot.update({ brush: { type: 'path' } });
expect(plot.chart.interactions['brush-x']).not.toBeDefined();
expect(plot.chart.interactions['brush']).toBeDefined();

plot.update({ brush: { type: 'y-rect' } });
expect(plot.chart.interactions['brush-x']).not.toBeDefined();
expect(plot.chart.interactions['brush-y']).toBeDefined();

plot.update({ brush: { type: 'y', action: 'highlight' } });
plot.update({ brush: { type: 'y-rect', action: 'highlight' } });
expect(plot.chart.interactions['brush-y']).not.toBeDefined();
expect(plot.chart.interactions['brush-y-highlight']).toBeDefined();

plot.update({ brush: { type: 'x', action: 'highlight' } });
plot.update({ brush: { type: 'x-rect', action: 'highlight' } });
expect(plot.chart.interactions['brush-x']).not.toBeDefined();
expect(plot.chart.interactions['brush-y-highlight']).not.toBeDefined();
expect(plot.chart.interactions['brush-x-highlight']).toBeDefined();
Expand Down
15 changes: 11 additions & 4 deletions __tests__/unit/plots/scatter/interaction-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,27 @@ describe('scatter: register interaction', () => {
});
expect(plot.chart.interactions['brush']).toBeDefined();

plot.update({ brush: { type: 'x' } });
plot.update({ brush: { type: 'circle' } });
expect(plot.chart.interactions['brush']).toBeDefined();

plot.update({ brush: { type: 'x-rect' } });
// 不同 brush 是互斥的
expect(plot.chart.interactions['brush']).not.toBeDefined();
expect(plot.chart.interactions['brush-x']).toBeDefined();

plot.update({ brush: { type: 'y' } });
plot.update({ brush: { type: 'path' } });
expect(plot.chart.interactions['brush-x']).not.toBeDefined();
expect(plot.chart.interactions['brush']).toBeDefined();

plot.update({ brush: { type: 'y-rect' } });
expect(plot.chart.interactions['brush-x']).not.toBeDefined();
expect(plot.chart.interactions['brush-y']).toBeDefined();

plot.update({ brush: { type: 'y', action: 'highlight' } });
plot.update({ brush: { type: 'y-rect', action: 'highlight' } });
expect(plot.chart.interactions['brush-y']).not.toBeDefined();
expect(plot.chart.interactions['brush-y-highlight']).toBeDefined();

plot.update({ brush: { type: 'x', action: 'highlight' } });
plot.update({ brush: { type: 'x-rect', action: 'highlight' } });
expect(plot.chart.interactions['brush-x']).not.toBeDefined();
expect(plot.chart.interactions['brush-y-highlight']).not.toBeDefined();
expect(plot.chart.interactions['brush-x-highlight']).toBeDefined();
Expand Down

0 comments on commit ae4b2f4

Please sign in to comment.