mirror of
https://github.com/vale981/apollo-server
synced 2025-03-05 09:41:40 -05:00
Fix test typings
This commit is contained in:
parent
63f6b4790b
commit
3ad0c43b82
3 changed files with 12 additions and 17 deletions
|
@ -1,18 +1,19 @@
|
|||
/// <reference types="jest" />
|
||||
|
||||
import {
|
||||
fetch,
|
||||
Request,
|
||||
Response,
|
||||
BodyInit,
|
||||
Headers,
|
||||
HeadersInit,
|
||||
URL,
|
||||
URLSearchParams,
|
||||
} from 'apollo-server-env';
|
||||
|
||||
type Headers = { [name: string]: string };
|
||||
} from '../packages/apollo-server-env';
|
||||
|
||||
interface FetchMock extends jest.Mock<typeof fetch> {
|
||||
mockResponseOnce(data?: any, headers?: Headers, status?: number);
|
||||
mockJSONResponseOnce(data?: object, headers?: Headers);
|
||||
mockResponseOnce(data?: any, headers?: HeadersInit, status?: number);
|
||||
mockJSONResponseOnce(data?: object, headers?: HeadersInit);
|
||||
}
|
||||
|
||||
const mockFetch = jest.fn<typeof fetch>() as FetchMock;
|
||||
|
@ -42,11 +43,4 @@ mockFetch.mockJSONResponseOnce = (
|
|||
);
|
||||
};
|
||||
|
||||
export = {
|
||||
fetch: mockFetch,
|
||||
Request,
|
||||
Response,
|
||||
Headers,
|
||||
URL,
|
||||
URLSearchParams,
|
||||
};
|
||||
export { mockFetch as fetch, Request, Response, Headers, URL, URLSearchParams };
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { fetch } from 'apollo-server-env';
|
||||
import { HTTPCache } from '../HTTPCache';
|
||||
import { fetch } from '../../../../__mocks__/apollo-server-env';
|
||||
|
||||
import {
|
||||
mockDate,
|
||||
|
@ -7,6 +6,8 @@ import {
|
|||
advanceTimeBy,
|
||||
} from '../../../../__mocks__/date';
|
||||
|
||||
import { HTTPCache } from '../HTTPCache';
|
||||
|
||||
describe('HTTPCache', () => {
|
||||
let store: Map<string, string>;
|
||||
let httpCache: HTTPCache;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { fetch } from 'apollo-server-env';
|
||||
import { fetch } from '../../../../__mocks__/apollo-server-env';
|
||||
|
||||
import {
|
||||
ApolloError,
|
||||
AuthenticationError,
|
||||
ForbiddenError,
|
||||
} from 'apollo-server-errors';
|
||||
import { RESTDataSource } from '../RESTDataSource';
|
||||
import { RESTDataSource, Request } from '../RESTDataSource';
|
||||
|
||||
import { HTTPCache } from '../HTTPCache';
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue