All files / src test-utils.tsx

100% Statements 16/16
100% Branches 2/2
100% Functions 3/3
100% Lines 14/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 3023x 23x 23x   23x 23x 23x   23x 23x             46x 46x 46x             23x 46x   23x  
import * as React from 'react';
import ApolloClient from 'apollo-client';
import { InMemoryCache as Cache } from 'apollo-cache-inmemory';
 
import { ApolloProvider } from './index';
import { MockLink } from './test-links';
export * from './test-links';
 
export class MockedProvider extends React.Component<any, any> {
  static defaultProps = {
    addTypename: true,
  };
 
  private client: any;
 
  constructor(props: any, context: any) {
    super(props, context);
    const link = new MockLink(this.props.mocks, this.props.addTypename);
    this.client = new ApolloClient({
      link,
      cache: new Cache({ addTypename: this.props.addTypename }),
      defaultOptions: this.props.defaultOptions,
    });
  }
 
  render() {
    return <ApolloProvider client={this.client}>{this.props.children}</ApolloProvider>;
  }
}