Skip to content

Instantly share code, notes, and snippets.

@danielbdias
Created July 6, 2018 17:40
Show Gist options
  • Save danielbdias/b7f34f4dded6f9e6094b38642d03f310 to your computer and use it in GitHub Desktop.
Save danielbdias/b7f34f4dded6f9e6094b38642d03f310 to your computer and use it in GitHub Desktop.
Test a resolve in one of the simple-graphql-type.js fields
const { expect } = require(‘chai’)
const MyCustomType = require(‘./MyCustomType’)
describe(‘MyCustomType test’, () => {
it(‘checks aCustomResolvedField #resolve’, () => {
const testObject = {
myStringField: 'hello',
innerValues: {
innerField: 'world'
}
}
const fieldsConfig = MyCustomType._typeConfig.fields()
const expectedValue = testObject.innerValues.innerField
const obtainedValue = fieldsConfig.aCustomResolvedField.resolve(testObject)
expect(obtainedValue).to.be.equal(expectedValue)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment