-
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.
- Loading branch information
1 parent
6a10aa0
commit 7ab6b50
Showing
4 changed files
with
123 additions
and
1 deletion.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
elements/map/test/cases/hover/display-tooltip-for-layer.js
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,72 @@ | ||
import { html } from "lit"; | ||
import ecoRegionsFixture from "../../fixtures/ecoregions.json"; | ||
import hoverInteractionLayerFixture from "../../fixtures/hoverInteractionLayerId.json"; | ||
import vectorLayerStyleJson from "../../fixtures/hoverInteraction.json"; | ||
import { simulateEvent } from "../../utils/events"; | ||
|
||
/** | ||
* Tests to display tooltip on hover | ||
*/ | ||
const displayTooltipForLayer = () => { | ||
cy.intercept("https://openlayers.org/data/vector/ecoregions.json", (req) => { | ||
req.reply(ecoRegionsFixture); | ||
}); | ||
cy.intercept("https://foo.bar/baz.json", (req) => { | ||
req.reply(hoverInteractionLayerFixture); | ||
}); | ||
cy.mount( | ||
html`<eox-map | ||
.layers=${[ | ||
...vectorLayerStyleJson, | ||
{ | ||
type: "Vector", | ||
properties: { | ||
id: "targetLayer", | ||
}, | ||
source: { | ||
type: "Vector", | ||
format: "GeoJSON", | ||
url: "https://foo.bar/baz.json", | ||
}, | ||
interactions: [ | ||
{ | ||
type: "select", | ||
options: { | ||
id: "selectInteraction", | ||
condition: "pointermove", | ||
}, | ||
}, | ||
], | ||
}, | ||
]} | ||
> | ||
<eox-map-tooltip for="targetLayer"></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("exist"); | ||
cy.get("eox-map-tooltip") | ||
.shadow() | ||
.within(() => { | ||
cy.get("ul").should("exist"); | ||
cy.get("ul").children().should("have.length", 2); | ||
cy.get("ul>li").and(($lis) => { | ||
assert( | ||
$lis[1].textContent.includes("targetLayer"), | ||
"includes property from targetLayer", | ||
); | ||
}); | ||
}); | ||
}); | ||
}; | ||
|
||
export default displayTooltipForLayer; |
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,39 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": { | ||
"fromLayer": "targetLayer" | ||
}, | ||
"id": 1, | ||
"geometry": { | ||
"coordinates": [ | ||
[ | ||
[ | ||
49.37329931631518, | ||
75.25339585285323 | ||
], | ||
[ | ||
30.792756530335794, | ||
13.182720975583408 | ||
], | ||
[ | ||
131.51801085877827, | ||
13.182720975583408 | ||
], | ||
[ | ||
150.80216977046496, | ||
67.37626215156416 | ||
], | ||
[ | ||
49.37329931631518, | ||
75.25339585285323 | ||
] | ||
] | ||
], | ||
"type": "Polygon" | ||
} | ||
} | ||
] | ||
} |
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