aboutsummaryrefslogtreecommitdiff
path: root/tests/timing.test.ts
diff options
context:
space:
mode:
authornetop://ウィビ <paul@webb.page>2026-04-26 20:18:30 -0700
committernetop://ウィビ <paul@webb.page>2026-04-26 20:18:30 -0700
commit3c06c95f396b6e911076bc3291d5855ed01b5caa (patch)
tree17cd218339c52fbeee93d931303b04a3ff294f8b /tests/timing.test.ts
parentf059d97ab7f6d74d61139ac698cb871be7cb632e (diff)
downloadgraphiql-3c06c95f396b6e911076bc3291d5855ed01b5caa.tar.gz
graphiql-3c06c95f396b6e911076bc3291d5855ed01b5caa.zip
cleanup and ready for launch
Diffstat (limited to 'tests/timing.test.ts')
-rw-r--r--tests/timing.test.ts21
1 files changed, 15 insertions, 6 deletions
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<void> {
- 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<FetcherResult> {
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<FetcherResult> {
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<void> {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+}