-
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
b8a25be
commit 19189e3
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
elements/map/test/cases/select/add-select-interaction-to-existing-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,51 @@ | ||
import { html } from "lit"; | ||
import { simulateEvent } from "../../utils/events"; | ||
import ecoRegionsFixture from "../../fixtures/ecoregions.json"; | ||
import vectorLayerJson from "../../fixtures/vectorLayer.json"; | ||
|
||
/** | ||
* Tests to adds a select interaction to Vector layer | ||
*/ | ||
const addSelectInteractionVector = () => { | ||
cy.intercept("https://openlayers.org/data/vector/ecoregions.json", (req) => { | ||
req.reply(ecoRegionsFixture); | ||
}); | ||
const styleJson = JSON.parse(JSON.stringify(vectorLayerJson)); | ||
styleJson[0].minZoom = 3; | ||
|
||
cy.mount(html`<eox-map .zoom=${4} .layers=${styleJson}></eox-map>`).as( | ||
"eox-map", | ||
); | ||
|
||
cy.get("eox-map").and(($el) => { | ||
const eoxMap = $el[0]; | ||
|
||
eoxMap.map.on("loadend", () => { | ||
styleJson[0].interactions = [ | ||
{ | ||
type: "select", | ||
options: { | ||
id: "selectInteraction", | ||
condition: "click", | ||
style: { | ||
"stroke-color": "white", | ||
"stroke-width": 3, | ||
}, | ||
}, | ||
}, | ||
]; | ||
eoxMap.layers = styleJson; | ||
eoxMap.addEventListener("select", (evt) => { | ||
expect(evt.detail.feature, "adds interaction after update").to.exist; | ||
expect( | ||
eoxMap.map.getTargetElement().style.cursor, | ||
"changes cursor to pointer", | ||
).to.be.equal("pointer"); | ||
}); | ||
simulateEvent(eoxMap.map, "pointermove", 120, -140); | ||
simulateEvent(eoxMap.map, "click", 120, -140); | ||
}); | ||
}); | ||
}; | ||
|
||
export default addSelectInteractionVector; |
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