Skip to content

Commit 1bdf489

Browse files
authored
Move internal testing utilities to /internal and remove other deprecated testing utils (#12639)
1 parent e48485d commit 1bdf489

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+931
-941
lines changed

.api-reports/api-report-testing.api.md

Lines changed: 127 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,133 @@
44
55
```ts
66

7-
import { createMockClient } from '@apollo/client/testing/core';
8-
import { MockedResponse } from '@apollo/client/testing/core';
9-
import { MockLink } from '@apollo/client/testing/core';
10-
import { MockLinkOptions } from '@apollo/client/testing/core';
11-
import { mockObservableLink } from '@apollo/client/testing/core';
12-
import { mockSingleLink } from '@apollo/client/testing/core';
13-
import { MockSubscriptionLink } from '@apollo/client/testing/core';
14-
import { realisticDelay } from '@apollo/client/testing/core';
15-
import { ResultFunction } from '@apollo/client/testing/core';
16-
import { tick } from '@apollo/client/testing/core';
17-
import { wait } from '@apollo/client/testing/core';
18-
import { withErrorSpy } from '@apollo/client/testing/core';
19-
import { withLogSpy } from '@apollo/client/testing/core';
20-
import { withWarningSpy } from '@apollo/client/testing/core';
21-
22-
export { createMockClient }
23-
24-
export { MockedResponse }
25-
26-
export { MockLink }
27-
28-
export { MockLinkOptions }
29-
30-
export { mockObservableLink }
31-
32-
export { mockSingleLink }
33-
34-
export { MockSubscriptionLink }
35-
36-
export { realisticDelay }
37-
38-
export { ResultFunction }
39-
40-
export { tick }
41-
42-
export { wait }
43-
44-
export { withErrorSpy }
45-
46-
export { withLogSpy }
47-
48-
export { withWarningSpy }
7+
import { ApolloLink } from '@apollo/client/link';
8+
import type { DocumentNode } from 'graphql';
9+
import type { FetchResult } from '@apollo/client/link';
10+
import { Observable } from 'rxjs';
11+
import type { Operation } from '@apollo/client/link';
12+
import type { Unmasked } from '@apollo/client/masking';
13+
14+
// @internal @deprecated (undocumented)
15+
type CovariantUnaryFunction<out Arg, out Ret> = {
16+
fn(arg: Arg): Ret;
17+
}["fn"];
18+
19+
// @public @deprecated (undocumented)
20+
export type MockedRequest<TVariables = Record<string, any>> = MockLink.MockedRequest<TVariables>;
21+
22+
// @public @deprecated (undocumented)
23+
export type MockedResponse<TData = Record<string, any>, TVariables = Record<string, any>> = MockLink.MockedResponse<TData, TVariables>;
24+
25+
// @public (undocumented)
26+
export namespace MockLink {
27+
// (undocumented)
28+
export interface DefaultOptions {
29+
// (undocumented)
30+
delay?: MockLink.Delay;
31+
}
32+
// (undocumented)
33+
export type Delay = number | DelayFunction;
34+
// (undocumented)
35+
export type DelayFunction = (operation: Operation) => number;
36+
// (undocumented)
37+
export interface MockedRequest<TVariables = Record<string, any>> {
38+
// (undocumented)
39+
query: DocumentNode;
40+
// Warning: (ae-forgotten-export) The symbol "VariableMatcher" needs to be exported by the entry point index.d.ts
41+
//
42+
// (undocumented)
43+
variables?: TVariables | VariableMatcher<TVariables>;
44+
}
45+
// (undocumented)
46+
export interface MockedResponse<out TData = Record<string, any>, out TVariables = Record<string, any>> {
47+
// (undocumented)
48+
delay?: number | MockLink.DelayFunction;
49+
// (undocumented)
50+
error?: Error;
51+
// (undocumented)
52+
maxUsageCount?: number;
53+
// (undocumented)
54+
request: MockedRequest<TVariables>;
55+
// (undocumented)
56+
result?: FetchResult<Unmasked<TData>> | ResultFunction<FetchResult<Unmasked<TData>>, TVariables>;
57+
}
58+
// (undocumented)
59+
export interface Options {
60+
// (undocumented)
61+
defaultOptions?: DefaultOptions;
62+
// (undocumented)
63+
showWarnings?: boolean;
64+
}
65+
// Warning: (ae-forgotten-export) The symbol "CovariantUnaryFunction" needs to be exported by the entry point index.d.ts
66+
//
67+
// (undocumented)
68+
export type ResultFunction<T, V = Record<string, any>> = CovariantUnaryFunction<V, T>;
69+
}
70+
71+
// @public (undocumented)
72+
export class MockLink extends ApolloLink {
73+
constructor(mockedResponses: ReadonlyArray<MockLink.MockedResponse<Record<string, any>, Record<string, any>>>, options?: MockLink.Options);
74+
// (undocumented)
75+
addMockedResponse(mockedResponse: MockLink.MockedResponse): void;
76+
// (undocumented)
77+
static defaultOptions: MockLink.DefaultOptions;
78+
// (undocumented)
79+
operation: Operation;
80+
// (undocumented)
81+
request(operation: Operation): Observable<FetchResult> | null;
82+
// (undocumented)
83+
showWarnings: boolean;
84+
}
85+
86+
// @public @deprecated (undocumented)
87+
export type MockLinkOptions = MockLink.Options;
88+
89+
// @public (undocumented)
90+
export namespace MockSubscriptionLink {
91+
// (undocumented)
92+
export interface Result {
93+
// (undocumented)
94+
delay?: number;
95+
// (undocumented)
96+
error?: Error;
97+
// (undocumented)
98+
result?: FetchResult;
99+
}
100+
}
101+
102+
// @public (undocumented)
103+
export class MockSubscriptionLink extends ApolloLink {
104+
constructor();
105+
// (undocumented)
106+
onSetup(listener: any): void;
107+
// (undocumented)
108+
onUnsubscribe(listener: any): void;
109+
// (undocumented)
110+
operation?: Operation;
111+
// (undocumented)
112+
request(operation: Operation): Observable<FetchResult>;
113+
// (undocumented)
114+
setups: any[];
115+
// (undocumented)
116+
simulateComplete(): void;
117+
// (undocumented)
118+
simulateResult(result: MockSubscriptionLink.Result, complete?: boolean): void;
119+
// (undocumented)
120+
unsubscribers: any[];
121+
}
122+
123+
// @public (undocumented)
124+
export function realisticDelay({ min, max, }?: {
125+
min?: number;
126+
max?: number;
127+
}): MockLink.DelayFunction;
128+
129+
// @public @deprecated (undocumented)
130+
export type ResultFunction<T, V = Record<string, any>> = MockLink.ResultFunction<T, V>;
131+
132+
// @public (undocumented)
133+
type VariableMatcher<V = Record<string, any>> = CovariantUnaryFunction<V, boolean>;
49134

50135
// (No @packageDocumentation comment for this package)
51136

.api-reports/api-report-testing_core.api.md

Lines changed: 0 additions & 161 deletions
This file was deleted.

0 commit comments

Comments
 (0)