mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-06-06 21:58:46 +08:00
29 lines
972 B
TypeScript
29 lines
972 B
TypeScript
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
|
|
import { check_running } from "./pid_check.ts";
|
|
import { promiseState, sleep } from "./utils.ts";
|
|
|
|
Deno.test("promiseState_test", async () => {
|
|
const p1 = new Promise((res) => setTimeout(() => res(100), 100));
|
|
const p2 = new Promise((res) => setTimeout(() => res(200), 200));
|
|
const p3 = new Promise((_res, rej) => setTimeout(() => rej(300), 100));
|
|
|
|
async function getStates() {
|
|
console.log(await promiseState(p1));
|
|
console.log(await promiseState(p2));
|
|
console.log(await promiseState(p3));
|
|
}
|
|
|
|
console.log("Immediately after initiation:");
|
|
await getStates();
|
|
await sleep(100);
|
|
console.log("After waiting for 100ms:");
|
|
await getStates();
|
|
await Promise.allSettled([p1, p2, p3]);
|
|
});
|
|
|
|
Deno.test("Pid_Test", async () => {
|
|
if (Deno.build.os == "windows") {
|
|
assertEquals(await check_running(Deno.pid), true);
|
|
}
|
|
});
|