Merge pull request #1618 from Safelite/unit-test/csr-1733-1790
Loader tests
This commit is contained in:
commit
f88809243a
1 changed files with 54 additions and 0 deletions
|
|
@ -28,4 +28,58 @@ describe("loader.vue", () => {
|
||||||
loaderPosition: "left",
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue