Skip to content

Commit

Permalink
Merge pull request #27 from andrewgryan/feature/test-layer-group
Browse files Browse the repository at this point in the history
Add tests to cover removal from layer group
  • Loading branch information
andrewgryan authored Jul 15, 2024
2 parents 8c561eb + 1f6e89c commit 0924dea
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/l-layer-group.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,29 @@ it("should register layers", async () => {
};
expect(actual).toEqual(expected);
});

it("should support removed layers from a group", async () => {
const root = document.createElement("l-layer-group");
const marker = document.createElement("l-marker");
marker.setAttribute("lat-lng", "[0,0]");
root.appendChild(marker);
document.body.appendChild(root);

// System under test
marker.remove();

// Wait one animation frame to allow MutationObserver
// to process el.remove()
const frame = new Promise((resolve) => {
window.requestAnimationFrame(() => {
resolve();
});
});
await frame;

// Assertions
const group = root.layer;
const actual = group.hasLayer(group.getLayerId(marker.layer));
const expected = false;
expect(actual).toEqual(expected);
});

0 comments on commit 0924dea

Please sign in to comment.