Skip to content

Commit

Permalink
Update the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
abdonrd committed Oct 16, 2019
1 parent b4ba6a9 commit 15caf00
Show file tree
Hide file tree
Showing 3 changed files with 513 additions and 519 deletions.
2 changes: 1 addition & 1 deletion loader.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

const os = require('os');
const gql = require('./src');
import gql from "./src";

// Takes `source` (the source GraphQL query string)
// and `doc` (the parsed GraphQL document) and tacks on
Expand Down
237 changes: 117 additions & 120 deletions test/graphql-v0.12.js
Original file line number Diff line number Diff line change
@@ -1,138 +1,135 @@
const gqlRequire = require("../src");
const gqlDefault = require("../src").default;
const assert = require("chai").assert;
import { assert } from "chai";
import gql from "../src";

[gqlRequire, gqlDefault].forEach((gql, i) => {
describe(`gql ${i}`, () => {
it("is correct for a simple query", () => {
const ast = gql`
{
user(id: 5) {
firstName
lastName
}
describe(`gql`, () => {
it("is correct for a simple query", () => {
const ast = gql`
{
user(id: 5) {
firstName
lastName
}
`;
}
`;

assert.equal(ast.kind, "Document");
assert.deepEqual(ast.definitions, [
{
kind: "OperationDefinition",
operation: "query",
name: undefined,
variableDefinitions: [],
directives: [],
selectionSet: {
kind: "SelectionSet",
selections: [
{
kind: "Field",
alias: undefined,
name: {
kind: "Name",
value: "user"
},
arguments: [
assert.equal(ast.kind, "Document");
assert.deepEqual(ast.definitions, [
{
kind: "OperationDefinition",
operation: "query",
name: undefined,
variableDefinitions: [],
directives: [],
selectionSet: {
kind: "SelectionSet",
selections: [
{
kind: "Field",
alias: undefined,
name: {
kind: "Name",
value: "user"
},
arguments: [
{
kind: "Argument",
name: {
kind: "Name",
value: "id"
},
value: {
kind: "IntValue",
value: "5"
}
}
],
directives: [],
selectionSet: {
kind: "SelectionSet",
selections: [
{
kind: "Argument",
kind: "Field",
alias: undefined,
name: {
kind: "Name",
value: "id"
value: "firstName"
},
value: {
kind: "IntValue",
value: "5"
}
}
],
directives: [],
selectionSet: {
kind: "SelectionSet",
selections: [
{
kind: "Field",
alias: undefined,
name: {
kind: "Name",
value: "firstName"
},
arguments: [],
directives: [],
selectionSet: undefined
arguments: [],
directives: [],
selectionSet: undefined
},
{
kind: "Field",
alias: undefined,
name: {
kind: "Name",
value: "lastName"
},
{
kind: "Field",
alias: undefined,
name: {
kind: "Name",
value: "lastName"
},
arguments: [],
directives: [],
selectionSet: undefined
}
]
}
arguments: [],
directives: [],
selectionSet: undefined
}
]
}
]
}
}
]
}
]);
});
}
]);
});

it("is correct for a fragment", () => {
const ast = gql`
fragment UserFragment on User {
firstName
lastName
}
`;
it("is correct for a fragment", () => {
const ast = gql`
fragment UserFragment on User {
firstName
lastName
}
`;

assert.equal(ast.kind, "Document");
assert.deepEqual(ast.definitions, [
{
kind: "FragmentDefinition",
assert.equal(ast.kind, "Document");
assert.deepEqual(ast.definitions, [
{
kind: "FragmentDefinition",
name: {
kind: "Name",
value: "UserFragment"
},
typeCondition: {
kind: "NamedType",
name: {
kind: "Name",
value: "UserFragment"
},
typeCondition: {
kind: "NamedType",
name: {
kind: "Name",
value: "User"
}
},
directives: [],
selectionSet: {
kind: "SelectionSet",
selections: [
{
kind: "Field",
alias: undefined,
name: {
kind: "Name",
value: "firstName"
},
arguments: [],
directives: [],
selectionSet: undefined
},
{
kind: "Field",
alias: undefined,
name: {
kind: "Name",
value: "lastName"
},
arguments: [],
directives: [],
selectionSet: undefined
}
]
value: "User"
}
},
directives: [],
selectionSet: {
kind: "SelectionSet",
selections: [
{
kind: "Field",
alias: undefined,
name: {
kind: "Name",
value: "firstName"
},
arguments: [],
directives: [],
selectionSet: undefined
},
{
kind: "Field",
alias: undefined,
name: {
kind: "Name",
value: "lastName"
},
arguments: [],
directives: [],
selectionSet: undefined
}
]
}
]);
});
}
]);
});
});
Loading

0 comments on commit 15caf00

Please sign in to comment.