All files / lib/src test-utils.js

87.5% Statements 28/32
58.82% Branches 10/17
81.82% Functions 9/11
92.59% Lines 25/27

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 5123x 23x     23x 23x 23x 23x                 23x 23x   53x 53x 53x         53x 53x   23x 53x   23x 21x 1x   20x 20x 2x   20x 2x     23x     23x      
var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
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';
var MockedProvider = (function (_super) {
    __extends(MockedProvider, _super);
    function MockedProvider(props) {
        var _this = _super.call(this, props) || this;
        var _a = _this.props, mocks = _a.mocks, addTypename = _a.addTypename, defaultOptions = _a.defaultOptions;
        var client = new ApolloClient({
            cache: new Cache({ addTypename: addTypename }),
            defaultOptions: defaultOptions,
            link: new MockLink(mocks || [], addTypename),
        });
        _this.state = { client: client };
        return _this;
    }
    MockedProvider.prototype.render = function () {
        return React.createElement(ApolloProvider, { client: this.state.client }, this.props.children);
    };
    MockedProvider.prototype.componentWillUnmount = function () {
        if (!this.state.client.queryManager) {
            return;
        }
        var scheduler = this.state.client.queryManager.scheduler;
        Object.keys(scheduler.registeredQueries).forEach(function (queryId) {
            scheduler.stopPollingQuery(queryId);
        });
        Object.keys(scheduler.intervalQueries).forEach(function (interval) {
            scheduler.fetchQueriesOnInterval(interval);
        });
    };
    MockedProvider.defaultProps = {
        addTypename: true,
    };
    return MockedProvider;
}(React.Component));
export { MockedProvider };
//# sourceMappingURL=test-utils.js.map