mirror of
https://github.com/vale981/apollo-server
synced 2025-03-05 17:51: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 {
|
import {
|
||||||
fetch,
|
fetch,
|
||||||
Request,
|
Request,
|
||||||
Response,
|
Response,
|
||||||
BodyInit,
|
BodyInit,
|
||||||
Headers,
|
Headers,
|
||||||
|
HeadersInit,
|
||||||
URL,
|
URL,
|
||||||
URLSearchParams,
|
URLSearchParams,
|
||||||
} from 'apollo-server-env';
|
} from '../packages/apollo-server-env';
|
||||||
|
|
||||||
type Headers = { [name: string]: string };
|
|
||||||
|
|
||||||
interface FetchMock extends jest.Mock<typeof fetch> {
|
interface FetchMock extends jest.Mock<typeof fetch> {
|
||||||
mockResponseOnce(data?: any, headers?: Headers, status?: number);
|
mockResponseOnce(data?: any, headers?: HeadersInit, status?: number);
|
||||||
mockJSONResponseOnce(data?: object, headers?: Headers);
|
mockJSONResponseOnce(data?: object, headers?: HeadersInit);
|
||||||
}
|
}
|
||||||
|
|
||||||
const mockFetch = jest.fn<typeof fetch>() as FetchMock;
|
const mockFetch = jest.fn<typeof fetch>() as FetchMock;
|
||||||
|
@ -42,11 +43,4 @@ mockFetch.mockJSONResponseOnce = (
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export = {
|
export { mockFetch as fetch, Request, Response, Headers, URL, URLSearchParams };
|
||||||
fetch: mockFetch,
|
|
||||||
Request,
|
|
||||||
Response,
|
|
||||||
Headers,
|
|
||||||
URL,
|
|
||||||
URLSearchParams,
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { fetch } from 'apollo-server-env';
|
import { fetch } from '../../../../__mocks__/apollo-server-env';
|
||||||
import { HTTPCache } from '../HTTPCache';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
mockDate,
|
mockDate,
|
||||||
|
@ -7,6 +6,8 @@ import {
|
||||||
advanceTimeBy,
|
advanceTimeBy,
|
||||||
} from '../../../../__mocks__/date';
|
} from '../../../../__mocks__/date';
|
||||||
|
|
||||||
|
import { HTTPCache } from '../HTTPCache';
|
||||||
|
|
||||||
describe('HTTPCache', () => {
|
describe('HTTPCache', () => {
|
||||||
let store: Map<string, string>;
|
let store: Map<string, string>;
|
||||||
let httpCache: HTTPCache;
|
let httpCache: HTTPCache;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { fetch } from 'apollo-server-env';
|
import { fetch } from '../../../../__mocks__/apollo-server-env';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ApolloError,
|
ApolloError,
|
||||||
AuthenticationError,
|
AuthenticationError,
|
||||||
ForbiddenError,
|
ForbiddenError,
|
||||||
} from 'apollo-server-errors';
|
} from 'apollo-server-errors';
|
||||||
import { RESTDataSource } from '../RESTDataSource';
|
import { RESTDataSource, Request } from '../RESTDataSource';
|
||||||
|
|
||||||
import { HTTPCache } from '../HTTPCache';
|
import { HTTPCache } from '../HTTPCache';
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue