From 3c06c95f396b6e911076bc3291d5855ed01b5caa Mon Sep 17 00:00:00 2001 From: "netop://ウィビ" Date: Sun, 26 Apr 2026 20:18:30 -0700 Subject: cleanup and ready for launch --- tests/timing.test.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'tests/timing.test.ts') diff --git a/tests/timing.test.ts b/tests/timing.test.ts index e2a0a06..589443d 100644 --- a/tests/timing.test.ts +++ b/tests/timing.test.ts @@ -8,15 +8,15 @@ import { expect, test } from "vitest"; /*** UTILITY ------------------------------------------ ***/ -import type { Fetcher, FetcherResult } from "../source/library/fetcher/types.ts"; -import { SessionStore } from "../source/library/state/session.svelte.ts"; import { createMemoryStorage } from "../source/library/state/storage.ts"; +import { SessionStore } from "../source/library/state/session.svelte.ts"; -function delay(ms: number): Promise { - return new Promise((resolve) => setTimeout(resolve, ms)); -} +import { + type Fetcher, + type FetcherResult +} from "../source/library/fetcher/types.ts"; -/*** TESTS -------------------------------------------- ***/ +/*** PROGRAM ------------------------------------------ ***/ test("run() populates timing for a one-shot fetcher", async () => { const store = new SessionStore(createMemoryStorage()); @@ -54,8 +54,10 @@ test("run() records intervals between async iterable payloads", async () => { async function* stream(): AsyncGenerator { yield { data: { n: 1 } }; await delay(5); + yield { data: { n: 2 } }; await delay(5); + yield { data: { n: 3 } }; } @@ -88,6 +90,7 @@ test("run() resets timing and streamIntervals on each invocation", async () => { async function* stream(): AsyncGenerator { yield { data: { n: 1 } }; await delay(5); + yield { data: { n: 2 } }; } @@ -98,3 +101,9 @@ test("run() resets timing and streamIntervals on each invocation", async () => { expect(tab.streamIntervals.length).toEqual(0); expect(tab.timing).not.toBeNull(); }); + +/*** HELPER ------------------------------------------- ***/ + +function delay(ms: number): Promise { + return new Promise((resolve) => setTimeout(resolve, ms)); +} -- cgit v1.2.3