Skip to content

Commit

Permalink
resolved pr comment
Browse files Browse the repository at this point in the history
  • Loading branch information
XantreDev committed Jul 20, 2023
1 parent 15a1e18 commit eb94f67
Showing 1 changed file with 18 additions and 26 deletions.
44 changes: 18 additions & 26 deletions packages/preact/test/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,42 +181,34 @@ describe("@preact/signals", () => {

render(<App x={sig} />, scratch);

{
const text = scratch.firstChild!.firstChild!;
let text = scratch.firstChild!.firstChild!;

expect(text.textContent).to.equal("test");
expect(text).to.be.an.instanceOf(HTMLSpanElement);
expect(text).to.have.property("firstChild").that.is.an.instanceOf(Text);
}
expect(text.textContent).to.equal("test");
expect(text).to.be.an.instanceOf(HTMLSpanElement);
expect(text).to.have.property("firstChild").that.is.an.instanceOf(Text);
sig.value = "a";
rerender();
{
const text = scratch.firstChild!.firstChild!;
expect(text.nodeType).to.equal(Node.TEXT_NODE);
expect(text.textContent).to.equal("a");
text = scratch.firstChild!.firstChild!;
expect(text.nodeType).to.equal(Node.TEXT_NODE);
expect(text.textContent).to.equal("a");

sig.value = "b";
expect(text.textContent).to.equal("b");
}
sig.value = "b";
expect(text.textContent).to.equal("b");

sig.value = <div>c</div>;
rerender();
await sleep();
{
const text = scratch.firstChild!.firstChild!;
text = scratch.firstChild!.firstChild!;

expect(text).to.be.an.instanceOf(HTMLDivElement);
expect(text.textContent).to.equal("c");
}
{
sig.value = <span>d</span>;
rerender();
await sleep();
expect(text).to.be.an.instanceOf(HTMLDivElement);
expect(text.textContent).to.equal("c");
sig.value = <span>d</span>;
rerender();
await sleep();

const text = scratch.firstChild!.firstChild!;
expect(text).to.be.an.instanceOf(HTMLSpanElement);
expect(text.textContent).to.equal("d");
}
text = scratch.firstChild!.firstChild!;
expect(text).to.be.an.instanceOf(HTMLSpanElement);
expect(text.textContent).to.equal("d");
});
});

Expand Down

0 comments on commit eb94f67

Please sign in to comment.