Skip to content

Commit

Permalink
Failing tests for hotwired#1288
Browse files Browse the repository at this point in the history
  • Loading branch information
tpaulshippy committed Jul 29, 2024
1 parent 14284e6 commit ee8e150
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/tests/unit/stream_element_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,17 @@ test("action=after", async () => {
assert.isNull(element.parentElement)
})


test("action=after with children ID already present in target", async () => {
subject.fixtureHTML = `<div id="hello"><div id="top">Top</div><div id="middle">Middle</div><div id="bottom">Bottom</div></div>`
const element = createStreamElement("after", "top", createTemplateElement(' <div id="middle">New Middle</div> tail1 '))

subject.append(element)
await nextAnimationFrame()

assert.equal(subject.find("#hello")?.textContent, "Top New Middle tail1 Bottom")
})

test("action=before", async () => {
const element = createStreamElement("before", "hello", createTemplateElement(`<h1 id="before">Before Turbo</h1>`))
assert.equal(subject.find("#hello")?.textContent, "Hello Turbo")
Expand All @@ -170,6 +181,17 @@ test("action=before", async () => {
assert.isNull(element.parentElement)
})


test("action=before with children ID already present in target", async () => {
subject.fixtureHTML = `<div id="hello"><div id="top">Top</div><div id="middle">Middle</div><div id="bottom">Bottom</div></div>`
const element = createStreamElement("before", "bottom", createTemplateElement(' <div id="middle">New Middle</div> tail1 '))

subject.append(element)
await nextAnimationFrame()

assert.equal(subject.find("#hello")?.textContent, "Top New Middle tail1 Bottom")
})

test("test action=refresh", async () => {
document.body.setAttribute("data-modified", "")
assert.ok(document.body.hasAttribute("data-modified"))
Expand Down

0 comments on commit ee8e150

Please sign in to comment.