UNPKG

3.61 kBTypeScriptView Raw
1import { DocumentNode } from 'graphql';
2import { TestOperation, Operation } from './operation';
3export declare type MatchOperationFn = (op: Operation) => boolean;
4export declare type MatchOperation = string | DocumentNode | Operation | MatchOperationFn;
5/**
6 * Controller to be injected into tests, that allows for mocking and flushing
7 * of operations.
8 *
9 *
10 */
11export declare abstract class ApolloTestingController {
12 /**
13 * Search for operations that match the given parameter, without any expectations.
14 */
15 abstract match(match: MatchOperation): TestOperation[];
16 /**
17 * Expect that a single operation has been made which matches the given URL, and return its
18 * mock.
19 *
20 * If no such operation has been made, or more than one such operation has been made, fail with an
21 * error message including the given operation description, if any.
22 */
23 abstract expectOne(operationName: string, description?: string): TestOperation;
24 /**
25 * Expect that a single operation has been made which matches the given parameters, and return
26 * its mock.
27 *
28 * If no such operation has been made, or more than one such operation has been made, fail with an
29 * error message including the given operation description, if any.
30 */
31 abstract expectOne(op: Operation, description?: string): TestOperation;
32 /**
33 * Expect that a single operation has been made which matches the given predicate function, and
34 * return its mock.
35 *
36 * If no such operation has been made, or more than one such operation has been made, fail with an
37 * error message including the given operation description, if any.
38 */
39 abstract expectOne(matchFn: MatchOperationFn, description?: string): TestOperation;
40 /**
41 * Expect that a single operation has been made which matches the given condition, and return
42 * its mock.
43 *
44 * If no such operation has been made, or more than one such operation has been made, fail with an
45 * error message including the given operation description, if any.
46 */
47 abstract expectOne(match: MatchOperation, description?: string): TestOperation;
48 /**
49 * Expect that no operations have been made which match the given URL.
50 *
51 * If a matching operation has been made, fail with an error message including the given
52 * description, if any.
53 */
54 abstract expectNone(operationName: string, description?: string): void;
55 /**
56 * Expect that no operations have been made which match the given parameters.
57 *
58 * If a matching operation has been made, fail with an error message including the given
59 * description, if any.
60 */
61 abstract expectNone(op: Operation, description?: string): void;
62 /**
63 * Expect that no operations have been made which match the given predicate function.
64 *
65 * If a matching operation has been made, fail with an error message including the given
66 * description, if any.
67 */
68 abstract expectNone(matchFn: MatchOperationFn, description?: string): void;
69 /**
70 * Expect that no operations have been made which match the given condition.
71 *
72 * If a matching operation has been made, fail with an error message including the given
73 * description, if any.
74 */
75 abstract expectNone(match: MatchOperation, description?: string): void;
76 /**
77 * Verify that no unmatched operations are outstanding.
78 *
79 * If any operations are outstanding, fail with an error message indicating which operations were not
80 * handled.
81 */
82 abstract verify(): void;
83}