How to use the apollo-link-http.createHttpLink.mock function in apollo-link-http

To help you get started, we’ve selected a few apollo-link-http examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apollographql / apollo-link / packages / apollo-link-batch-http / src / __tests__ / batchHttpLink.ts View on Github external
createHttpLink: jest.fn(() => ({ request })),
      };
    });

    const createHttpLink = require('apollo-link-http').createHttpLink;
    const LocalScopedLink = require('../batchHttpLink').BatchHttpLink;

    const reduceFetchOptions = () => {};

    const batch = new LocalScopedLink({
      batchInterval: 20,
      batchMax: 20,
      reduceFetchOptions,
    });

    const { batchOptions } = createHttpLink.mock.calls[0][0];
    expect(batchOptions.batchInterval).toBe(20);
    expect(batchOptions.batchMax).toBe(20);
    expect(batchOptions.reduceFetchOptions).toEqual(reduceFetchOptions);

    const { request } = createHttpLink();
    execute(batch, operation);
    expect(request).toBeCalled();
  });
});

apollo-link-http

HTTP transport layer for GraphQL

MIT
Latest version published 5 years ago

Package Health Score

64 / 100
Full package analysis