All files / src/__tests__/utils index.ts

56.25% Statements 9/16
0% Branches 0/2
0% Functions 0/2
56.25% Lines 9/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 602x 2x 2x   2x                                     2x           2x 2x           2x                                   2x          
import { InMemoryCache } from 'apollo-cache-inmemory'
import ApolloClient from 'apollo-client'
import gql from 'graphql-tag'
 
export const schema = gql`
  extend type Todo {
    id: ID!
    asignee: String!
    description: String!
    completed: Boolean!
  }
  input CreateInput {
    asignee: String!
    description: String!
  }
  extend type Query {
    getTodos: [Todo]
  }
  extend type Mutation {
    testResolve: Boolean!
  }
`
 
export const statesToPublish = [
  { testResolve: 'First' },
  { testResolve: 'Second' },
  { testResolve: 'Third' },
]
 
const cache = new InMemoryCache()
cache.writeData({
  data: {
    getTodos: [],
  },
})
 
export const client = new ApolloClient({
  resolvers: {
    Mutation: {
      testResolve: async (_, __, context) => {
        if (!context._rootSub) {
          return false
        }
        context._rootSub.next(statesToPublish[0])
        context._rootSub.next(statesToPublish[1])
        context._rootSub.next(statesToPublish[2])
        return true
      },
    },
  },
  cache,
  typeDefs: schema,
})
 
export const TEST_RESOLVER = gql`
  mutation testResolve {
    testResolve @client
  }
`