From ae4b2f4e7e69ca08b9416ff2cd11df9fed12c547 Mon Sep 17 00:00:00 2001 From: visiky <736929286@qq.com> Date: Fri, 23 Jul 2021 16:44:57 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E4=BF=AE=E6=94=B9=20brush=20=E5=8D=95?= =?UTF-8?q?=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __tests__/unit/plots/bar/interaction-spec.ts | 15 +++++++++++---- __tests__/unit/plots/column/interaction-spec.ts | 15 +++++++++++---- __tests__/unit/plots/scatter/interaction-spec.ts | 15 +++++++++++---- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/__tests__/unit/plots/bar/interaction-spec.ts b/__tests__/unit/plots/bar/interaction-spec.ts index 47678904a9..0b1d745580 100644 --- a/__tests__/unit/plots/bar/interaction-spec.ts +++ b/__tests__/unit/plots/bar/interaction-spec.ts @@ -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(); diff --git a/__tests__/unit/plots/column/interaction-spec.ts b/__tests__/unit/plots/column/interaction-spec.ts index d4ac0d63ae..54315aca48 100644 --- a/__tests__/unit/plots/column/interaction-spec.ts +++ b/__tests__/unit/plots/column/interaction-spec.ts @@ -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(); diff --git a/__tests__/unit/plots/scatter/interaction-spec.ts b/__tests__/unit/plots/scatter/interaction-spec.ts index 50f61587a0..b3241f7a6c 100644 --- a/__tests__/unit/plots/scatter/interaction-spec.ts +++ b/__tests__/unit/plots/scatter/interaction-spec.ts @@ -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();