Skip to content

Commit

Permalink
🌿 use promiseState instead deadline
Browse files Browse the repository at this point in the history
  • Loading branch information
Milly committed May 4, 2024
1 parent 1779146 commit 48f877d
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions session_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import {
assertRejects,
assertThrows,
} from "https://deno.land/std@0.210.0/assert/mod.ts";
import {
deadline,
DeadlineError,
} from "https://deno.land/std@0.210.0/async/mod.ts";
import { promiseState } from "https://deno.land/x/async@v2.1.0/state.ts";
import {
Channel,
channel,
Expand Down Expand Up @@ -224,12 +221,10 @@ Deno.test("Session.wait", async (t) => {
session.start();

const waiter = session.wait();
await assertRejects(
() => deadline(waiter, 100),
DeadlineError,
);
assertEquals(await promiseState(waiter), "pending");
// Process all messages
guard.resolve();
await deadline(waiter, 100);
assertEquals(await promiseState(waiter), "fulfilled");
},
);

Expand Down Expand Up @@ -295,13 +290,10 @@ Deno.test("Session.shutdown", async (t) => {
session.start();
await session.send(["redraw", ""]);
const shutdown = session.shutdown();
await assertRejects(
() => deadline(shutdown, 100),
DeadlineError,
);
assertEquals(await promiseState(shutdown), "pending");
// Process all messages
guard.resolve();
await deadline(shutdown, 100);
assertEquals(await promiseState(shutdown), "fulfilled");
},
);
});
Expand Down Expand Up @@ -350,7 +342,7 @@ Deno.test("Session.forceShutdown", async (t) => {
session.start();
session.send(["redraw", ""]); // Do NOT await
const shutdown = session.forceShutdown();
await deadline(shutdown, 100);
assertEquals(await promiseState(shutdown), "fulfilled");
},
);
});

0 comments on commit 48f877d

Please sign in to comment.