Skip to content

Commit 0eb18e1

Browse files
committed
test: 增加图例highligh模式单测
1 parent 4c0aa0f commit 0eb18e1

7 files changed

+37
-1
lines changed

packages/f2/src/chart/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,9 @@ class Chart<
369369

370370
getHighlightStyle(record) {
371371
const { highlights } = this.state;
372+
let isHighLight = false;
372373
if (isEmpty(highlights)) return;
373374

374-
let isHighLight = false;
375375
each(highlights, (condition, field) => {
376376
if (condition(record[field], record)) {
377377
isHighLight = true;
12.2 KB
Loading
13.4 KB
Loading
13.7 KB
Loading
13.3 KB
Loading
12.2 KB
Loading

packages/f2/test/components/legend/interval.test.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,40 @@ describe('Interval', () => {
4343
await delay(800);
4444
expect(context).toMatchImageSnapshot();
4545
});
46+
47+
it('legend highlight 模式点击', async () => {
48+
const context = createContext();
49+
const { type, props } = (
50+
<Canvas context={context} pixelRatio={1}>
51+
<Chart data={data}>
52+
<Legend clickMode="highlight" />
53+
<Axis field="genre" />
54+
<Axis field="sold" />
55+
<Interval x="genre" y="sold" color="genre" />
56+
</Chart>
57+
</Canvas>
58+
);
59+
60+
const canvas = new Canvas(props);
61+
await canvas.render();
62+
63+
await delay(800);
64+
expect(context).toMatchImageSnapshot();
65+
66+
await gestureSimulator(context.canvas, 'click', { x: 165, y: 26 });
67+
await delay(500);
68+
expect(context).toMatchImageSnapshot();
69+
70+
await gestureSimulator(context.canvas, 'click', { x: 109, y: 24 });
71+
await delay(500);
72+
expect(context).toMatchImageSnapshot();
73+
74+
await gestureSimulator(context.canvas, 'click', { x: 165, y: 26 });
75+
await delay(800);
76+
expect(context).toMatchImageSnapshot();
77+
78+
await gestureSimulator(context.canvas, 'click', { x: 165, y: 26 });
79+
await delay(800);
80+
expect(context).toMatchImageSnapshot();
81+
});
4682
});

0 commit comments

Comments
 (0)