graphql-engine/frontend/libs/open-api-to-graphql/test/weather_underground.test.ts
Varun Choudhary 35d9c059db console: open api to graphql library
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9420
Co-authored-by: Nicolas Beaussart <7281023+beaussan@users.noreply.github.com>
GitOrigin-RevId: 31d983ae8573c91ac5bf11066770f776941c3a11
2023-06-13 19:58:02 +00:00

37 lines
1.0 KiB
TypeScript

// Copyright IBM Corp. 2017,2018. All Rights Reserved.
// Node module: openapi-to-graphql
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
import { afterAll, beforeAll, expect, test } from '@jest/globals';
import { GraphQLObjectType, GraphQLSchema } from 'graphql';
import * as openAPIToGraphQL from '../src/index';
// Set up the schema first
const oas = require('./fixtures/weather_underground.json');
let createdSchema: GraphQLSchema;
beforeAll(() => {
return openAPIToGraphQL
.createGraphQLSchema(oas)
.then(({ schema, report }) => {
createdSchema = schema;
});
});
test('All Weather Underground query endpoints present', () => {
let oasGetCount = 0;
for (let path in oas.paths) {
for (let method in oas.paths[path]) {
if (method === 'get') oasGetCount++;
}
}
const gqlTypes = Object.keys(
(createdSchema.getTypeMap().Query as GraphQLObjectType).getFields()
).length;
expect(gqlTypes).toEqual(oasGetCount);
});