UNPKG

chimp

Version:

Your development companion for doing quality, faster.

63 lines (55 loc) 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const getInterfaces_1 = tslib_1.__importDefault(require("./getInterfaces")); const gql = (a) => a[0]; test('get the interfaces', () => { const schemaString = gql ` type TodoItem @key(fields: "id") { id: ID! list: List } extend type List { id: ID! todos: [TodoItem!]! incompleteCount: Int! } type InMemory { id: ID! } type Query { homes: [Home] } interface Home { address: string } `; const res = (0, getInterfaces_1.default)(schemaString); expect(res).toEqual(['Home']); }); test('should throw error if duplicate interface names are found', () => { const schemaString = gql ` type TodoItem @key(fields: "id") { id: ID! list: List } interface Home { address: string } extend type List { id: ID! todos: [TodoItem!]! incompleteCount: Int! } type InMemory { id: ID! } type Query { homes: [Home] } interface Home { address: string } `; expect(() => (0, getInterfaces_1.default)(schemaString)).toThrow('Duplicate interface name found: Home'); });