From b14de0396809cf7d65c041879834d889c5b848b7 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Mon, 13 Jul 2020 02:40:28 +0300 Subject: [PATCH] introspection-test: simplify tests for description fields (#2708) --- src/type/__tests__/introspection-test.js | 136 ++++++----------------- 1 file changed, 36 insertions(+), 100 deletions(-) diff --git a/src/type/__tests__/introspection-test.js b/src/type/__tests__/introspection-test.js index dead5b1e71..6b22998625 100644 --- a/src/type/__tests__/introspection-test.js +++ b/src/type/__tests__/introspection-test.js @@ -1252,79 +1252,40 @@ describe('Introspection', () => { }); }); - it('exposes descriptions on types and fields', () => { + it('exposes descriptions', () => { const schema = buildSchema(` - type Query { - someField: String + """Enum description""" + enum SomeEnum { + """Value description""" + VALUE } - `); - const source = ` - { - schemaType: __type(name: "__Schema") { - name, - description, - fields { - name, - description - } - } + """Object description""" + type SomeObject { + """Field description""" + someField(arg: SomeEnum): String } - `; - expect(graphqlSync({ schema, source })).to.deep.equal({ - data: { - schemaType: { - name: '__Schema', - description: - 'A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.', - fields: [ - { - name: 'description', - description: null, - }, - { - name: 'types', - description: 'A list of all types supported by this server.', - }, - { - name: 'queryType', - description: 'The type that query operations will be rooted at.', - }, - { - name: 'mutationType', - description: - 'If this server supports mutation, the type that mutation operations will be rooted at.', - }, - { - name: 'subscriptionType', - description: - 'If this server support subscription, the type that subscription operations will be rooted at.', - }, - { - name: 'directives', - description: 'A list of all directives supported by this server.', - }, - ], - }, - }, - }); - }); - - it('exposes descriptions on enums', () => { - const schema = buildSchema(` - type Query { - someField: String + """Schema description""" + schema { + query: SomeObject } `); const source = ` { - typeKindType: __type(name: "__TypeKind") { - name, + Schema: __schema { description } + SomeObject: __type(name: "SomeObject") { description, + fields { + name + description + } + } + SomeEnum: __type(name: "SomeEnum") { + description enumValues { - name, + name description } } @@ -1333,49 +1294,24 @@ describe('Introspection', () => { expect(graphqlSync({ schema, source })).to.deep.equal({ data: { - typeKindType: { - name: '__TypeKind', - description: - 'An enum describing what kind of type a given `__Type` is.', + Schema: { + description: 'Schema description', + }, + SomeEnum: { + description: 'Enum description', enumValues: [ { - name: 'SCALAR', - description: 'Indicates this type is a scalar.', - }, - { - name: 'OBJECT', - description: - 'Indicates this type is an object. `fields` and `interfaces` are valid fields.', - }, - { - name: 'INTERFACE', - description: - 'Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields.', - }, - { - name: 'UNION', - description: - 'Indicates this type is a union. `possibleTypes` is a valid field.', - }, - { - name: 'ENUM', - description: - 'Indicates this type is an enum. `enumValues` is a valid field.', - }, - { - name: 'INPUT_OBJECT', - description: - 'Indicates this type is an input object. `inputFields` is a valid field.', - }, - { - name: 'LIST', - description: - 'Indicates this type is a list. `ofType` is a valid field.', + name: 'VALUE', + description: 'Value description', }, + ], + }, + SomeObject: { + description: 'Object description', + fields: [ { - name: 'NON_NULL', - description: - 'Indicates this type is a non-null. `ofType` is a valid field.', + name: 'someField', + description: 'Field description', }, ], },