Skip to content

Commit

Permalink
chore: refactor test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Oct 3, 2024
1 parent e5b2ca1 commit 4913fe1
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/layers/6_client/raw/client.raw.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { describe, expectTypeOf } from 'vitest'
import { test } from '../../../../tests/_/helpers.js'
import { gql } from '../../6_helpers/gql.js'
import type { RawResolveOutputReturnRootType } from '../handleOutput.js'

describe(`TypedQueryDocumentNode`, () => {
describe(`data`, () => {
const document = gql<{ id: string }, {}>`query { id }`
test(`envelope data is typed`, ({ kitchenSink: g }) => {
type ExpectedType = RawResolveOutputReturnRootType<typeof g._.context.config, { id: string }>
expectTypeOf(g.raw({ document })).resolves.toEqualTypeOf<ExpectedType>()
test(`envelope data is typed`, async ({ kitchenSink: g }) => {
expectTypeOf(await g.raw({ document })).toEqualTypeOf<null | { id: string }>()
})
test(`variables are not allowed to be passed in`, async ({ kitchenSink: g }) => {
// @ts-expect-error - variables not allowed.
Expand All @@ -19,9 +17,7 @@ describe(`TypedQueryDocumentNode`, () => {
describe(`data + optional variables`, () => {
const document = gql<{ id: string }, { filter?: boolean }>`query { id }`
test(`envelope data is typed`, ({ kitchenSink: g }) => {
expectTypeOf(g.raw({ document })).resolves.toEqualTypeOf<
RawResolveOutputReturnRootType<typeof g._.context.config, { id: string }>
>()
expectTypeOf(g.raw({ document })).resolves.toEqualTypeOf<{ id: string } | null>()
})
test(`variables are typed and allowed to be passed in or omitted`, async ({ kitchenSink: g }) => {
// Expect no type errors below
Expand Down

0 comments on commit 4913fe1

Please sign in to comment.