diff options
| author | netop://ウィビ <paul@webb.page> | 2026-04-26 20:18:30 -0700 |
|---|---|---|
| committer | netop://ウィビ <paul@webb.page> | 2026-04-26 20:18:30 -0700 |
| commit | 3c06c95f396b6e911076bc3291d5855ed01b5caa (patch) | |
| tree | 17cd218339c52fbeee93d931303b04a3ff294f8b /tests/session-io.test.ts | |
| parent | f059d97ab7f6d74d61139ac698cb871be7cb632e (diff) | |
| download | graphiql-3c06c95f396b6e911076bc3291d5855ed01b5caa.tar.gz graphiql-3c06c95f396b6e911076bc3291d5855ed01b5caa.zip | |
cleanup and ready for launch
Diffstat (limited to 'tests/session-io.test.ts')
| -rw-r--r-- | tests/session-io.test.ts | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/tests/session-io.test.ts b/tests/session-io.test.ts index 6de919b..88c1ee6 100644 --- a/tests/session-io.test.ts +++ b/tests/session-io.test.ts @@ -16,29 +16,7 @@ import { type TabInput = Parameters<typeof tabToExport>[0]; -function validExport(): SessionExport { - return { - exportedAt: "2026-04-24T00:00:00.000Z", - tabs: [ - { - headers: "{}", - operationName: "MyOp", - query: "query MyOp { hello }", - title: "MyOp", - variables: "{}" - } - ], - version: 1 - }; -} - -function isError(result: unknown): result is { error: string } { - return typeof result === "object" && - result !== null && - "error" in result; -} - -/*** TESTS -------------------------------------------- ***/ +/*** PROGRAM ------------------------------------------ ***/ test("validateSessionExport round-trips a valid payload unchanged", () => { const data = validExport(); @@ -58,6 +36,7 @@ test("validateSessionExport rejects non-object input", () => { test("validateSessionExport rejects wrong version", () => { const zero = validateSessionExport({ ...validExport(), version: 0 }); const two = validateSessionExport({ ...validExport(), version: 2 }); + const missing = validateSessionExport({ exportedAt: "2026-04-24T00:00:00.000Z", tabs: [] @@ -142,6 +121,7 @@ test("validateSessionExport accepts null operationName", () => { test("validateSessionExport rejects string field > 1 MB", () => { const big = "x".repeat(1024 * 1024 + 1); + const result = validateSessionExport({ exportedAt: "2026-04-24T00:00:00.000Z", tabs: [ @@ -167,6 +147,7 @@ test("validateSessionExport rejects > 50 tabs", () => { title: "t", variables: "{}" })); + const result = validateSessionExport({ exportedAt: "2026-04-24T00:00:00.000Z", tabs, @@ -199,3 +180,27 @@ test("tabToExport strips id, result, operations, titleDirty", () => { variables: "{}" }); }); + +/*** HELPER ------------------------------------------- ***/ + +function isError(result: unknown): result is { error: string } { + return typeof result === "object" && + result !== null && + "error" in result; +} + +function validExport(): SessionExport { + return { + exportedAt: "2026-04-24T00:00:00.000Z", + tabs: [ + { + headers: "{}", + operationName: "MyOp", + query: "query MyOp { hello }", + title: "MyOp", + variables: "{}" + } + ], + version: 1 + }; +} |