Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/graphql-toolset / src / __tests__ / validate.test.ts
Size: Mime:
import { ApolloError } from 'apollo-server'
import { validateGraphQLResponse as validate } from '../validateGraphQLResponse'

describe('validateGraphQLResponse', () => {
  it('should throw for single error response', () => {
    const response = { error: new ApolloError('#single') }
    expect(() => validate(response)).toThrow('#single')
  })
  it('should throw for multiple error response', () => {
    const response = {
      errors: [new ApolloError('#one'), new ApolloError('#two')],
    }
    expect(() => validate(response)).toThrow('#on')
  })
  it('should log/warn for responses without data', () => {
    const response = { data: undefined }
    expect(() => validate(response)).not.toThrow()
  })
  it('should not throw for empty array of errors', () => {
    const response = { errors: [] }
    expect(() => validate(response)).not.toThrow()
  })
  it('should successfully identify valid responses', () => {
    const response = { data: { isValid: true } }
    expect(() => validate(response)).not.toThrow()
  })
})