Skip to content

Commit

Permalink
Remove unnecessary sleeps
Browse files Browse the repository at this point in the history
  • Loading branch information
luisherranz committed Feb 5, 2023
1 parent 953b0fe commit 758b188
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions packages/deepsignal/test/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import "@preact/signals";
// @ts-ignore
import { createElement, createRef, render } from "preact";
import { setupRerender } from "preact/test-utils";
import { deepSignal, useDeepSignal, type DeepSignal } from "deepsignal";

const sleep = (ms?: number) => new Promise(r => setTimeout(r, ms));

describe("deepsignal", () => {
describe("deepsignal (preact)", () => {
let scratch: HTMLDivElement;
let rerender: () => void;

Expand Down Expand Up @@ -56,7 +54,6 @@ describe("deepsignal", () => {
// Should update the text in-place.
expect(text).to.have.property("data", "changed");

await sleep();
expect(spy).not.to.have.been.called;
});

Expand All @@ -77,15 +74,13 @@ describe("deepsignal", () => {
expect(scratch.firstChild).to.have.property("value", "updated");

// Ensure the component was never re-rendered: (even after a tick).
await sleep();
expect(spy).not.to.have.been.called;

state.test = "second update";

expect(scratch.firstChild).to.have.property("value", "second update");

// Ensure the component was never re-rendered: (even after a tick).
await sleep();
expect(spy).not.to.have.been.called;
});
});
Expand Down Expand Up @@ -163,8 +158,6 @@ describe("deepsignal", () => {
expect(spy).to.be.calledOnce;
const stateAfterRender = state!;

await sleep(1);

state!.test = "updated";
rerender();

Expand Down

0 comments on commit 758b188

Please sign in to comment.