Skip to content

Instantly share code, notes, and snippets.

@TheMagoo73
Created March 31, 2020 11:26
Show Gist options
  • Save TheMagoo73/acc0e60a44bc5e616af3fee7d00bc6b3 to your computer and use it in GitHub Desktop.
Save TheMagoo73/acc0e60a44bc5e616af3fee7d00bc6b3 to your computer and use it in GitHub Desktop.
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