All files / src/__tests__/utils mockClient.ts

92.86% Statements 13/14
50% Branches 1/2
100% Functions 2/2
92.86% Lines 13/14

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 322x 2x 2x   2x 2x           2x   2x     4x   4x     4x 4x 4x 4x              
import { InMemoryCache } from 'apollo-cache-inmemory'
import ApolloClient from 'apollo-client'
import { schema } from './schema'
 
const cache = new InMemoryCache()
cache.writeData({
    data: {
        getTodos: []
    }
})
 
export const statesToPublish = [{ testResolve: "First"}, { testResolve: "Second"}, { testResolve: "Third"}]
 
export const client = new ApolloClient({
    resolvers: {
      Mutation: {
          testResolve: async (_, __, context) => {
 
            Iif(!context._rootSub){
              return false
            }
            context._rootSub.next(statesToPublish[0])
            context._rootSub.next(statesToPublish[1])
            context._rootSub.next(statesToPublish[2])
            return true
        }
      }
    },
    cache,
    typeDefs: schema
})