Skip to content

Commit

Permalink
Merge pull request #33 from Patternslib/different-markup-test
Browse files Browse the repository at this point in the history
maint: Add test showing a different than the proposed markup structure.
  • Loading branch information
thet authored Jan 15, 2025
2 parents 84ca744 + 6a3e948 commit a9f7650
Showing 1 changed file with 20 additions and 0 deletions.
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

0 comments on commit a9f7650

Please sign in to comment.