-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(interaction): interaction can be clear
- Loading branch information
Showing
4 changed files
with
109 additions
and
19 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
__tests__/integration/api-chart-render-clear-interaction.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { CustomEvent as GCustomEvent } from '@antv/g'; | ||
import { chartRenderClearInteraction as render } from '../plots/api/chart-render-clear-interaction'; | ||
import { PLOT_CLASS_NAME } from '../../src'; | ||
import { createDOMGCanvas } from './utils/createDOMGCanvas'; | ||
import './utils/useSnapshotMatchers'; | ||
import './utils/useCustomFetch'; | ||
|
||
describe('chart.render', () => { | ||
const dir = `${__dirname}/snapshots/api`; | ||
const canvas = createDOMGCanvas(640, 480); | ||
|
||
it('chart.interaction(name, false) should clear interaction.', async () => { | ||
const { finished } = render({ | ||
canvas, | ||
container: document.createElement('div'), | ||
}); | ||
await finished; | ||
|
||
// Trigger tooltip | ||
const plot = canvas.document.getElementsByClassName(PLOT_CLASS_NAME)[0]; | ||
plot.dispatchEvent( | ||
new GCustomEvent('pointermove', { | ||
offsetX: 200, | ||
offsetY: 300, | ||
}), | ||
); | ||
await expect(canvas).toMatchDOMSnapshot(dir, render.name, { | ||
selector: '.g2-tooltip', | ||
}); | ||
}); | ||
|
||
afterAll(() => { | ||
canvas?.destroy(); | ||
}); | ||
}); |
1 change: 1 addition & 0 deletions
1
__tests__/integration/snapshots/api/chartRenderClearInteraction.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Chart } from '../../../src'; | ||
|
||
export function chartRenderClearInteraction(context) { | ||
const { container, canvas } = context; | ||
|
||
const chart = new Chart({ | ||
container, | ||
canvas, | ||
}); | ||
|
||
chart.options({ | ||
theme: 'classic', | ||
type: 'line', | ||
clip: true, | ||
data: { | ||
type: 'fetch', | ||
value: 'data/aapl.csv', | ||
}, | ||
encode: { | ||
x: 'date', | ||
y: 'close', | ||
}, | ||
}); | ||
|
||
const finished = chart.render().then(() => { | ||
chart.options({ interaction: { tooltip: false } }); | ||
return chart.render(); | ||
}); | ||
|
||
return { chart, finished }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters