Skip to content

Commit

Permalink
add test for disabling tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertOrthofer committed Dec 4, 2024
1 parent f2a58c5 commit 27187e8
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
34 changes: 34 additions & 0 deletions elements/map/test/cases/hover/disable-tooltip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { html } from "lit";
import ecoRegionsFixture from "../../fixtures/ecoregions.json";
import vectorLayerStyleJson from "../../fixtures/hoverInteraction.json";
import { simulateEvent } from "../../utils/events";

/**
* Tests to disable the default hover tooltip
*/
const disableTooltip = () => {
cy.intercept("https://openlayers.org/data/vector/ecoregions.json", (req) => {
req.reply(ecoRegionsFixture);
});
const layers = JSON.parse(JSON.stringify(vectorLayerStyleJson));
layers[0].interactions[0].options.tooltip = false;
cy.mount(
html`<eox-map .layers=${layers}>
<eox-map-tooltip></eox-map-tooltip>
</eox-map>`,
).as("eox-map");
cy.get("eox-map").and(($el) => {
const eoxMap = $el[0];

eoxMap.map.on("loadend", () => {
simulateEvent(eoxMap.map, "pointermove", 120, -140);
});
});
cy.get("eox-map")
.shadow()
.within(() => {
cy.get("eox-map-tooltip").should("not.exist");
});
};

export default disableTooltip;
1 change: 1 addition & 0 deletions elements/map/test/cases/hover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
export { default as addSelectInteraction } from "./add-select-interaction";
export { default as selectAfterReArrangingLayers } from "./select-after-re-arranging-layers";
export { default as displayTooltip } from "./display-tooltip";
export { default as disableTooltip } from "./disable-tooltip";
export { default as displayTooltipOneLayerVisible } from "./display-tooltip-one-layer-visible";
11 changes: 10 additions & 1 deletion elements/map/test/tooltip.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import "../src/main";
import { displayTooltip, displayTooltipOneLayerVisible } from "./cases/hover";
import {
displayTooltip,
disableTooltip,
displayTooltipOneLayerVisible,
} from "./cases/hover";

/**
* Test suite for the EOX Map to load Tooltip
Expand All @@ -10,6 +14,11 @@ describe("tooltip", () => {
*/
it("displays a tooltip on hover", () => displayTooltip());

/**
* Test case to disable the default tooltip
*/
it("disable the default tooltip", () => disableTooltip());

/**
* Test case to displays a tooltip on hover when multiple layers are initialized and only one visible
*/
Expand Down

0 comments on commit 27187e8

Please sign in to comment.