-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: propagate item click event * fix: only trigger on actual item click * feat: add pointermove event * chore: fix typo * chore: rename event to follow best practices * feat(test): check that click outside of bar item does not trigger event
- Loading branch information
1 parent
56edaf0
commit 7e686b0
Showing
6 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
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
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
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
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,40 @@ | ||
import { TEST_SELECTORS, TEST_VALUES } from "../../src/enums"; | ||
|
||
// Destructure TEST_SELECTORS object | ||
const { chart } = TEST_SELECTORS; | ||
|
||
// Destructuring TEST_VALUES object | ||
const { chartSpec } = TEST_VALUES; | ||
|
||
/** | ||
* Test to verify if the chart registers the click on items correctly. | ||
*/ | ||
const clickChartTest = () => { | ||
cy.get(chart).and(($el) => { | ||
const eoxChart = $el[0]; | ||
eoxChart.spec = chartSpec; | ||
}); | ||
|
||
const clickEventHandlerSpy = cy.spy(); | ||
cy.get(chart).and(($chart) => { | ||
$chart.get(0).addEventListener("click:item", clickEventHandlerSpy); | ||
}); | ||
|
||
// eslint-disable-next-line cypress/unsafe-to-chain-command | ||
cy.get(chart) | ||
// click on axis title | ||
.click(5, 100) | ||
.then(() => { | ||
expect(clickEventHandlerSpy).to.not.be.called; | ||
}); | ||
|
||
// eslint-disable-next-line cypress/unsafe-to-chain-command | ||
cy.get(chart) | ||
// click on bar | ||
.click(50, 100) | ||
.then(() => { | ||
expect(clickEventHandlerSpy).to.be.calledOnce; | ||
}); | ||
}; | ||
|
||
export default clickChartTest; |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { default as loadChartTest } from "./load-chart"; | ||
export { default as setDataValuesTest } from "./set-data-values"; | ||
export { default as clickChartTest } from "./click-chart"; |
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