Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/pat-content-mirror.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,26 @@ describe("pat-content-mirror", () => {
);
});

it("Works also with other than the default proposed markup structure.", async () => {
document.body.innerHTML = `
<section class="the-mirror"></section>
<textarea
class="pat-content-mirror"
data-pat-content-mirror="target:.the-mirror"></textarea>
`;

const instance = new Pattern(document.querySelector(".pat-content-mirror"));
await events.await_pattern_init(instance);

const textarea = document.querySelector("textarea");
textarea.value = "this is a test text.";
textarea.dispatchEvent(new Event("input"));

expect(document.querySelector(".the-mirror").textContent).toBe(
"this is a test text."
);
});

it("works with multiple content mirrors.", async () => {
document.body.innerHTML = `
<p class="mirror-1"><span class="text"></span></p>
Expand Down
Loading