Repository URL to install this package:
|
Version:
1.2.19 ▾
|
"use strict";
var _graphql = require("graphql");
var _src = require("../src");
describe("Interface", () => {
test(`create Interface`, () => {
class MyInterface extends _src.Interface {}
expect(MyInterface.typeName).toBe("MyInterface");
expect(MyInterface.description).toBe(undefined);
});
test(`create Interface custom settings`, () => {
class MyInterface extends _src.Interface {}
MyInterface.typeName = "MyInterfaceType";
MyInterface.description = "MyInterfaceType Description";
expect(MyInterface.typeName).toBe("MyInterfaceType");
expect(MyInterface.description).toBe("MyInterfaceType Description");
});
test(`create Interface with fields`, () => {
class MyInterface extends _src.Interface {}
MyInterface.description = "My Description";
MyInterface.fields = {
hello: new _src.Field(_src.String)
};
expect(Object.keys(MyInterface.fields)).toEqual(["hello"]);
const gql = MyInterface.gql;
expect(gql).toBeInstanceOf(_graphql.GraphQLInterfaceType);
expect(gql.name).toBe("MyInterface");
expect(gql.description).toBe("My Description");
expect(Object.keys(gql.getFields())).toEqual(["hello"]);
});
});