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 May 12, 2021
1 parent 419ee9d commit 33bd13d
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 33bd13d

Please sign in to comment.