From 4a091a25b04b231b8b5540c301d0ba9f278fe572 Mon Sep 17 00:00:00 2001 From: nodkz Date: Sat, 30 May 2020 13:43:42 +0600 Subject: [PATCH] test: add test for custom typename in `query.auth` path --- .../__snapshots__/astToSchema-test.ts.snap | 4 ++-- .../__snapshots__/directoryToAst-test.ts.snap | 22 ++++++++++++++++++- .../__testSchema__/query.auth/index.ts | 3 +++ src/__tests__/directoryToAst-test.ts | 10 ++++++++- 4 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 src/__tests__/__testSchema__/query.auth/index.ts diff --git a/src/__tests__/__snapshots__/astToSchema-test.ts.snap b/src/__tests__/__snapshots__/astToSchema-test.ts.snap index 19b25f0..c9e617f 100644 --- a/src/__tests__/__snapshots__/astToSchema-test.ts.snap +++ b/src/__tests__/__snapshots__/astToSchema-test.ts.snap @@ -12,7 +12,7 @@ type Query { me(arg: Int): QueryMe some: QuerySome user: UserAwesomeType - auth: QueryAuth + auth: NamespaceCustomTypeName } type QueryMe { @@ -45,7 +45,7 @@ type UserExtendedData { starsCount: Int } -type QueryAuth { +type NamespaceCustomTypeName { isLoggedIn: Boolean nested: QueryAuthNested } diff --git a/src/__tests__/__snapshots__/directoryToAst-test.ts.snap b/src/__tests__/__snapshots__/directoryToAst-test.ts.snap index 3a516b1..418e946 100644 --- a/src/__tests__/__snapshots__/directoryToAst-test.ts.snap +++ b/src/__tests__/__snapshots__/directoryToAst-test.ts.snap @@ -56,8 +56,28 @@ exports[`directoryToAst() Schema ./__testSchema__ query has proper values 1`] = Object { "absPath": Any, "children": Object { - "auth": ObjectContaining { + "auth": Object { + "absPath": Any, + "children": Object { + "isLoggedIn": ObjectContaining { + "kind": "file", + }, + "nested": ObjectContaining { + "kind": "dir", + }, + }, "kind": "dir", + "name": "auth", + "namespaceConfig": Object { + "absPath": "/Users/nodkz/www/_npm/graphql-compose-modules/src/__tests__/__testSchema__/query.auth/index.ts", + "code": Object { + "default": Object { + "type": "NamespaceCustomTypeName", + }, + }, + "kind": "file", + "name": "index", + }, }, "field": ObjectContaining { "kind": "file", diff --git a/src/__tests__/__testSchema__/query.auth/index.ts b/src/__tests__/__testSchema__/query.auth/index.ts new file mode 100644 index 0000000..d01e64a --- /dev/null +++ b/src/__tests__/__testSchema__/query.auth/index.ts @@ -0,0 +1,3 @@ +export default { + type: 'NamespaceCustomTypeName', +}; diff --git a/src/__tests__/directoryToAst-test.ts b/src/__tests__/directoryToAst-test.ts index 7e42c25..85106a6 100644 --- a/src/__tests__/directoryToAst-test.ts +++ b/src/__tests__/directoryToAst-test.ts @@ -14,7 +14,15 @@ describe('directoryToAst()', () => { kind: 'rootType', absPath: expect.any(String), children: { - auth: expect.objectContaining({ kind: 'dir' }), + auth: { + kind: 'dir', + name: 'auth', + absPath: expect.any(String), + children: { + isLoggedIn: expect.objectContaining({ kind: 'file' }), + nested: expect.objectContaining({ kind: 'dir' }), + }, + }, field: expect.objectContaining({ kind: 'file' }), me: { absPath: expect.any(String),