Skip to content

Commit

Permalink
chore: fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcc committed Dec 11, 2023
1 parent f1ac0f8 commit 8b10110
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ describe('chart.emit', () => {
chart.emit('tooltip:disable');
await sleep(20);

dispatchFirstElementEvent(barCanvas, 'pointerover');
dispatchFirstElementEvent(barCanvas, 'pointermove');
await expect(barCanvas).toMatchDOMSnapshot(dir, 'step0', {
selector: '.g2-tooltip',
});

chart.emit('tooltip:enable');

dispatchFirstElementEvent(barCanvas, 'pointerover');
dispatchFirstElementEvent(barCanvas, 'pointermove');
await expect(barCanvas).toMatchDOMSnapshot(dir, 'step1', {
selector: '.g2-tooltip',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('chart.emit', () => {
// chart.on("tooltip:hide") should be called when hiding tooltip.
const [tooltipHided, resolveHide] = createPromise();
chart.on('tooltip:hide', receiveExpectData(resolveHide, null));
dispatchFirstElementEvent(canvas, 'pointerout');
dispatchFirstElementEvent(canvas, 'pointerleave');
await tooltipHided;
});

Expand Down
4 changes: 2 additions & 2 deletions __tests__/integration/api-chart-emit-item-tooltip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ describe('chart.emit', () => {
// chart.on("tooltip:show", callback) should revive selected data.
const [tooltipShowed, resolveShow] = createPromise();
chart.on('tooltip:show', receiveExpectData(resolveShow));
dispatchFirstElementEvent(canvas, 'pointerover');
dispatchFirstElementEvent(canvas, 'pointermove');
await tooltipShowed;

// chart.on("tooltip:hide") should be called when hiding tooltip.
const [tooltipHided, resolveHide] = createPromise();
chart.on('tooltip:hide', receiveExpectData(resolveHide, null));
dispatchFirstElementEvent(canvas, 'pointerout');
dispatchFirstElementEvent(canvas, 'pointerleave');
await tooltipHided;
});

Expand Down
4 changes: 2 additions & 2 deletions __tests__/integration/api-chart-tooltip-multi-chart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ describe('chart.interaction.tooltip', () => {
});
await Promise.all([finished0, finished1]);

dispatchFirstElementEvent(canvas1, 'pointerover');
dispatchFirstElementEvent(canvas2, 'pointerover');
dispatchFirstElementEvent(canvas1, 'pointermove');
dispatchFirstElementEvent(canvas2, 'pointermove');
expect(
Array.from(document.body.getElementsByClassName('g2-tooltip')).length,
).toBe(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ stateAgesIntervalHighlightGroupBackground.steps = ({ canvas }) => {
{
skip: true,
changeState: () => {
e1.background.dispatchEvent(new CustomEvent('pointerover'));
e1.background.dispatchEvent(new CustomEvent('pointermove'));
},
},
step(e2, 'pointerover'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ alphabetIntervalTooltipRenderUpdate.steps = ({ canvas }) => {
await sleep(100);
const elements = document.getElementsByClassName(ELEMENT_CLASS_NAME);
const [e0] = elements;
e0.dispatchEvent(new CustomEvent('pointerover'));
e0.dispatchEvent(new CustomEvent('pointermove'));
},
},
{
changeState: async () => {
const elements = document.getElementsByClassName(ELEMENT_CLASS_NAME);
const [e0] = elements;
e0.dispatchEvent(new CustomEvent('pointerover'));
e0.dispatchEvent(new CustomEvent('pointermove'));
},
},
];
Expand Down
2 changes: 1 addition & 1 deletion __tests__/plots/tooltip/flare-treemap-poptip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ flareTreemapPoptip.steps = ({ canvas }) => {
},
{
changeState: async () => {
rectangle?.dispatchEvent(new CustomEvent('pointerout'));
rectangle?.dispatchEvent(new CustomEvent('pointerleave'));
},
skip: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ profitIntervalLegendFilterOrdinal.steps = ({ canvas }) => {
changeState: async () => {
const elements = document.getElementsByClassName(ELEMENT_CLASS_NAME);
const [e0] = elements;
e0.dispatchEvent(new CustomEvent('pointerover'));
e0.dispatchEvent(new CustomEvent('pointermove'));
},
},
];
Expand Down
4 changes: 2 additions & 2 deletions __tests__/plots/tooltip/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function tooltipSteps(...index) {
const elements = document.getElementsByClassName(ELEMENT_CLASS_NAME);
const steps = index.map((i) => ({
changeState: async () => {
elements[i].dispatchEvent(new CustomEvent('pointerover'));
elements[i].dispatchEvent(new CustomEvent('pointermove'));
},
}));
return steps;
Expand All @@ -40,7 +40,7 @@ export function tooltipStepsByMarkType(markType, ...index) {
);
const steps = index.map((i) => ({
changeState: async () => {
elements[i].dispatchEvent(new CustomEvent('pointerover'));
elements[i].dispatchEvent(new CustomEvent('pointermove'));
},
}));
return steps;
Expand Down
5 changes: 3 additions & 2 deletions src/interaction/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ export function seriesTooltip(
groupName,
emitter,
wait = 50,
leading = false,
leading = true,
trailing = false,
startX = 0,
startY = 0,
Expand Down Expand Up @@ -857,7 +857,7 @@ export function tooltip(

const addEventListeners = () => {
if (!disableNative) {
console.log(111, 'addEventListeners');
// root.addEventListener('pointerover', pointerover);
root.addEventListener('pointermove', pointerover);
// Only emit pointerleave event when the pointer is not in the root area.
// !! !DO NOT USE pointerout event, it will emit when the pointer is in the child area.
Expand All @@ -867,6 +867,7 @@ export function tooltip(

const removeEventListeners = () => {
if (!disableNative) {
// root.removeEventListener('pointerover', pointerover);
root.removeEventListener('pointermove', pointerover);
root.removeEventListener('pointerleave', pointerleave);
}
Expand Down

0 comments on commit 8b10110

Please sign in to comment.