Created
March 31, 2020 11:26
-
-
Save TheMagoo73/acc0e60a44bc5e616af3fee7d00bc6b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const chai = require('chai') | |
chai.should() | |
const { makeExecutableSchema } = require('graphql-tools') | |
const { graphql } = require('graphql') | |
const mockQuoteService = () => { | |
return "Foo is never a substitute for Bar" | |
} | |
const mockLogger = { | |
log: (msg) => {return} | |
} | |
describe("GraphQL", () =>{ | |
let schema | |
let context = {} | |
before(() => { | |
const typeDefs = require('../typedefs') | |
const resolvers = require('../resolvers') | |
schema = makeExecutableSchema({ typeDefs, resolvers }) | |
context.logger = mockLogger | |
context.getQuote = mockQuoteService | |
}) | |
it('can return a quote', async () => { | |
const query = ` | |
query { | |
quote | |
} | |
` | |
const expected = { | |
data: { | |
quote: "Foo is never a substitute for Bar" | |
} | |
} | |
const result = await graphql(schema, query, null, context, {}) | |
result.should.deep.equals(expected) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment