Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maint: Add test showing a different than the proposed markup structure. #33

Merged
merged 1 commit into from
Jan 15, 2025
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