Merge pull request #1618 from Safelite/unit-test/csr-1733-1790

Loader tests
This commit is contained in:
chloeherdsafelite 2023-12-06 11:00:39 -05:00 committed by GitHub
commit f88809243a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,4 +28,58 @@ describe("loader.vue", () => {
loaderPosition: "left",
});
});
describe("Blocking interaction on page", () => {
test("Does capture clicks if enabled (default)", async () => {
// Arrange
const div = document.createElement("div");
div.id = "parent";
document.body.appendChild(div);
const parentClickFn = jest.fn();
div.addEventListener("click", parentClickFn);
const wrapper = shallowMount(loader, {
props: {},
attachTo: "#parent",
});
// Act
await wrapper.trigger("click");
// Assert
expect(parentClickFn).not.toBeCalled();
// Cleanup
document.body.removeChild(div);
});
test("Does not capture clicks if disabled", async () => {
// Arrange
const div = document.createElement("div");
div.id = "parent";
document.body.appendChild(div);
const parentClickFn = jest.fn();
div.addEventListener("click", parentClickFn);
const wrapper = shallowMount(loader, {
props: {
allowPageInteraction: true,
},
attachTo: "#parent",
});
// Act
await wrapper.trigger("click");
// Assert
expect(parentClickFn).toBeCalled();
// Cleanup
document.body.removeChild(div);
});
});
});