Skip to content

Commit

Permalink
test: add basic initAll test
Browse files Browse the repository at this point in the history
  • Loading branch information
gregtyler committed Oct 28, 2022
1 parent d080161 commit 058a506
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/moj/all.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { getByText, getByTestId } = require("@testing-library/dom");

require("./helpers");
require("./all");

describe("initAll", () => {
test("initialises container", () => {
MOJFrontend.PasswordReveal = jest.fn();

const container = document.createElement("div");

container.innerHTML = `
<input data-module="moj-password-reveal" data-testid="password-reveal" type="password" />
`;

new MOJFrontend.initAll({ scope: container });

expect(MOJFrontend.PasswordReveal).toHaveBeenCalledWith(
getByTestId(container, "password-reveal")
);
});
});

0 comments on commit 058a506

Please sign in to comment.