1 |
|
2 | import {
|
3 | AllHTMLAttributes as ReactHTMLAttributes,
|
4 | Component,
|
5 | JSX,
|
6 | ReactElement,
|
7 | SVGAttributes as ReactSVGAttributes,
|
8 | } from "react";
|
9 |
|
10 | export type HTMLAttributes = ReactHTMLAttributes<{}> & ReactSVGAttributes<{}>;
|
11 |
|
12 | export class ElementClass extends Component<any, any> {}
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | export interface ComponentClass<Props> {
|
19 | new(props: Props, context?: any): Component<Props>;
|
20 | }
|
21 |
|
22 | export type FunctionComponent<Props> = (props: Props, context?: any) => JSX.Element | null;
|
23 |
|
24 | export type ComponentType<Props> = ComponentClass<Props> | FunctionComponent<Props>;
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | export interface EnzymePropSelector {
|
37 | [key: string]: any;
|
38 | }
|
39 | export type EnzymeSelector = string | FunctionComponent<any> | ComponentClass<any> | EnzymePropSelector;
|
40 |
|
41 | export type Intercepter<T> = (intercepter: T) => void;
|
42 |
|
43 | export interface CommonWrapper<P = {}, S = {}, C = Component<P, S>> {
|
44 | |
45 |
|
46 |
|
47 | filterWhere(predicate: (wrapper: this) => boolean): this;
|
48 |
|
49 | |
50 |
|
51 |
|
52 | contains(node: ReactElement | ReactElement[] | string | number): boolean;
|
53 |
|
54 | |
55 |
|
56 |
|
57 | containsMatchingElement(node: ReactElement | ReactElement[]): boolean;
|
58 |
|
59 | |
60 |
|
61 |
|
62 | containsAllMatchingElements(nodes: ReactElement[] | ReactElement[][]): boolean;
|
63 |
|
64 | |
65 |
|
66 |
|
67 | containsAnyMatchingElements(nodes: ReactElement[] | ReactElement[][]): boolean;
|
68 |
|
69 | |
70 |
|
71 |
|
72 | equals(node: ReactElement): boolean;
|
73 |
|
74 | |
75 |
|
76 |
|
77 | matchesElement(node: ReactElement): boolean;
|
78 |
|
79 | |
80 |
|
81 |
|
82 | hasClass(className: string | RegExp): boolean;
|
83 |
|
84 | |
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 | invoke<
|
91 | K extends NonNullable<
|
92 | {
|
93 | [K in keyof P]-?: P[K] extends ((...arg: any[]) => void) | undefined ? K : never;
|
94 | }[keyof P]
|
95 | >,
|
96 | >(
|
97 | invokePropName: K,
|
98 | ): P[K];
|
99 |
|
100 | |
101 |
|
102 |
|
103 | is(selector: EnzymeSelector): boolean;
|
104 |
|
105 | |
106 |
|
107 |
|
108 |
|
109 | isEmpty(): boolean;
|
110 |
|
111 | |
112 |
|
113 |
|
114 | exists(selector?: EnzymeSelector): boolean;
|
115 |
|
116 | |
117 |
|
118 |
|
119 |
|
120 | not(selector: EnzymeSelector): this;
|
121 |
|
122 | |
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 | text(): string;
|
130 |
|
131 | |
132 |
|
133 |
|
134 |
|
135 |
|
136 | html(): string;
|
137 |
|
138 | |
139 |
|
140 |
|
141 | get(index: number): ReactElement;
|
142 |
|
143 | |
144 |
|
145 |
|
146 | getNode(): ReactElement;
|
147 |
|
148 | |
149 |
|
150 |
|
151 | getNodes(): ReactElement[];
|
152 |
|
153 | |
154 |
|
155 |
|
156 | getElement(): ReactElement;
|
157 |
|
158 | |
159 |
|
160 |
|
161 | getElements(): ReactElement[];
|
162 |
|
163 | |
164 |
|
165 |
|
166 | getDOMNode<T extends Element = Element>(): T;
|
167 |
|
168 | |
169 |
|
170 |
|
171 | at(index: number): this;
|
172 |
|
173 | |
174 |
|
175 |
|
176 | first(): this;
|
177 |
|
178 | |
179 |
|
180 |
|
181 | last(): this;
|
182 |
|
183 | |
184 |
|
185 |
|
186 | slice(begin?: number, end?: number): this;
|
187 |
|
188 | |
189 |
|
190 |
|
191 | tap(intercepter: Intercepter<this>): this;
|
192 |
|
193 | |
194 |
|
195 |
|
196 | state(): S;
|
197 | state<K extends keyof S>(key: K): S[K];
|
198 | state<T>(key: string): T;
|
199 |
|
200 | |
201 |
|
202 |
|
203 | context(): any;
|
204 | context<T>(key: string): T;
|
205 |
|
206 | |
207 |
|
208 |
|
209 |
|
210 |
|
211 | props(): P;
|
212 |
|
213 | |
214 |
|
215 |
|
216 |
|
217 |
|
218 | prop<K extends keyof P>(key: K): P[K];
|
219 | prop<T>(key: string): T;
|
220 |
|
221 | |
222 |
|
223 |
|
224 |
|
225 | key(): string;
|
226 |
|
227 | |
228 |
|
229 |
|
230 |
|
231 |
|
232 | simulate(event: string, ...args: any[]): this;
|
233 |
|
234 | |
235 |
|
236 |
|
237 |
|
238 |
|
239 | simulateError(error: any): this;
|
240 |
|
241 | |
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 | setState<K extends keyof S>(state: Pick<S, K>, callback?: () => void): this;
|
252 |
|
253 | /**
|
254 | * A method that sets the props of the root component, and re-renders. Useful for when you are wanting to test
|
255 | * how the component behaves over time with changing props. Calling this, for instance, will call the
|
256 | * componentWillReceiveProps lifecycle method.
|
257 | *
|
258 | * Similar to setState, this method accepts a props object and will merge it in with the already existing props.
|
259 | * Returns itself.
|
260 | *
|
261 | * NOTE: can only be called on a wrapper instance that is also the root instance.
|
262 | */
|
263 | setProps<K extends keyof P>(props: Pick<P, K>, callback?: () => void): this;
|
264 |
|
265 | /**
|
266 | * A method that sets the context of the root component, and re-renders. Useful for when you are wanting to
|
267 | * test how the component behaves over time with changing contexts.
|
268 | * Returns itself.
|
269 | *
|
270 | * NOTE: can only be called on a wrapper instance that is also the root instance.
|
271 | */
|
272 | setContext(context: any): this;
|
273 |
|
274 | /**
|
275 | * Gets the instance of the component being rendered as the root node passed into shallow().
|
276 | *
|
277 | * NOTE: can only be called on a wrapper instance that is also the root instance.
|
278 | */
|
279 | instance(): C;
|
280 |
|
281 | /**
|
282 | * Forces a re-render. Useful to run before checking the render output if something external may be updating
|
283 | * the state of the component somewhere.
|
284 | * Returns itself.
|
285 | *
|
286 | * NOTE: can only be called on a wrapper instance that is also the root instance.
|
287 | */
|
288 | update(): this;
|
289 |
|
290 | /**
|
291 | * Returns an html-like string of the wrapper for debugging purposes. Useful to print out to the console when
|
292 | * tests are not passing when you expect them to.
|
293 | */
|
294 | debug(options?: {
|
295 |
|
296 | ignoreProps?: boolean | undefined;
|
297 |
|
298 | verbose?: boolean | undefined;
|
299 | }): string;
|
300 |
|
301 | /**
|
302 | * Returns the name of the current node of the wrapper.
|
303 | */
|
304 | name(): string;
|
305 |
|
306 | /**
|
307 | * Iterates through each node of the current wrapper and executes the provided function with a wrapper around
|
308 | * the corresponding node passed in as the first argument.
|
309 | *
|
310 | * Returns itself.
|
311 | * @param fn A callback to be run for every node in the collection. Should expect a ShallowWrapper as the first
|
312 | * argument, and will be run with a context of the original instance.
|
313 | */
|
314 | forEach(fn: (wrapper: this, index: number) => any): this;
|
315 |
|
316 | /**
|
317 | * Maps the current array of nodes to another array. Each node is passed in as a ShallowWrapper to the map
|
318 | * function.
|
319 | * Returns an array of the returned values from the mapping function..
|
320 | * @param fn A mapping function to be run for every node in the collection, the results of which will be mapped
|
321 | * to the returned array. Should expect a ShallowWrapper as the first argument, and will be run
|
322 | * with a context of the original instance.
|
323 | */
|
324 | map<V>(fn: (wrapper: this, index: number) => V): V[];
|
325 |
|
326 | /**
|
327 | * Applies the provided reducing function to every node in the wrapper to reduce to a single value. Each node
|
328 | * is passed in as a ShallowWrapper, and is processed from left to right.
|
329 | */
|
330 | reduce<R>(fn: (prevVal: R, wrapper: this, index: number) => R, initialValue?: R): R;
|
331 |
|
332 | /**
|
333 | * Applies the provided reducing function to every node in the wrapper to reduce to a single value.
|
334 | * Each node is passed in as a ShallowWrapper, and is processed from right to left.
|
335 | */
|
336 | reduceRight<R>(fn: (prevVal: R, wrapper: this, index: number) => R, initialValue?: R): R;
|
337 |
|
338 | /**
|
339 | * Returns whether or not any of the nodes in the wrapper match the provided selector.
|
340 | */
|
341 | some(selector: EnzymeSelector): boolean;
|
342 |
|
343 | /**
|
344 | * Returns whether or not any of the nodes in the wrapper pass the provided predicate function.
|
345 | */
|
346 | someWhere(fn: (wrapper: this) => boolean): boolean;
|
347 |
|
348 | /**
|
349 | * Returns whether or not all of the nodes in the wrapper match the provided selector.
|
350 | */
|
351 | every(selector: EnzymeSelector): boolean;
|
352 |
|
353 | /**
|
354 | * Returns whether or not all of the nodes in the wrapper pass the provided predicate function.
|
355 | */
|
356 | everyWhere(fn: (wrapper: this) => boolean): boolean;
|
357 |
|
358 | /**
|
359 | * Returns true if renderer returned null
|
360 | */
|
361 | isEmptyRender(): boolean;
|
362 |
|
363 | /**
|
364 | * Renders the component to static markup and returns a Cheerio wrapper around the result.
|
365 | */
|
366 | render(): cheerio.Cheerio;
|
367 |
|
368 | /**
|
369 | * Returns the type of the current node of this wrapper. If it's a composite component, this will be the
|
370 | * component constructor. If it's native DOM node, it will be a string of the tag name.
|
371 | *
|
372 | * Note: can only be called on a wrapper of a single node.
|
373 | */
|
374 | type(): string | ComponentClass<P> | FunctionComponent<P>;
|
375 |
|
376 | length: number;
|
377 | }
|
378 |
|
379 | export type Parameters<T> = T extends (...args: infer A) => any ? A : never;
|
380 |
|
381 | export interface ShallowWrapper<P = {}, S = {}, C = Component> extends CommonWrapper<P, S, C> {}
|
382 | export class ShallowWrapper<P = {}, S = {}, C = Component> {
|
383 | constructor(nodes: JSX.Element[] | JSX.Element, root?: ShallowWrapper<any, any>, options?: ShallowRendererProps);
|
384 | shallow(options?: ShallowRendererProps): ShallowWrapper<P, S>;
|
385 | unmount(): this;
|
386 |
|
387 | /**
|
388 | * Find every node in the render tree that matches the provided selector.
|
389 | * @param selector The selector to match.
|
390 | */
|
391 | find<P2>(statelessComponent: FunctionComponent<P2>): ShallowWrapper<P2, never>;
|
392 | find<P2>(component: ComponentType<P2>): ShallowWrapper<P2, any>;
|
393 | find<C2 extends Component>(
|
394 | componentClass: ComponentClass<C2["props"]>,
|
395 | ): ShallowWrapper<C2["props"], C2["state"], C2>;
|
396 | find(props: EnzymePropSelector): ShallowWrapper<any, any>;
|
397 | find(selector: string): ShallowWrapper<HTMLAttributes, any>;
|
398 |
|
399 | /**
|
400 | * Removes nodes in the current wrapper that do not match the provided selector.
|
401 | * @param selector The selector to match.
|
402 | */
|
403 | filter<P2>(statelessComponent: FunctionComponent<P2>): ShallowWrapper<P2, never>;
|
404 | filter<P2>(component: ComponentType<P2>): ShallowWrapper<P2, any>;
|
405 | filter(props: EnzymePropSelector | string): ShallowWrapper<P, S>;
|
406 |
|
407 | /**
|
408 | * Finds every node in the render tree that returns true for the provided predicate function.
|
409 | */
|
410 | findWhere(predicate: (wrapper: ShallowWrapper<any, any>) => boolean): ShallowWrapper<any, any>;
|
411 |
|
412 | /**
|
413 | * Returns a new wrapper with all of the children of the node(s) in the current wrapper. Optionally, a selector
|
414 | * can be provided and it will filter the children by this selector.
|
415 | */
|
416 | children<P2>(statelessComponent: FunctionComponent<P2>): ShallowWrapper<P2, never>;
|
417 | children<P2>(component: ComponentType<P2>): ShallowWrapper<P2, any>;
|
418 | children(selector: string): ShallowWrapper<HTMLAttributes, any>;
|
419 | children(props?: EnzymePropSelector): ShallowWrapper<any, any>;
|
420 |
|
421 | /**
|
422 | * Returns a new wrapper with child at the specified index.
|
423 | */
|
424 | childAt(index: number): ShallowWrapper<any, any>;
|
425 | childAt<P2, S2>(index: number): ShallowWrapper<P2, S2>;
|
426 |
|
427 | /**
|
428 | * Shallow render the one non-DOM child of the current wrapper, and return a wrapper around the result.
|
429 | * NOTE: can only be called on wrapper of a single non-DOM component element node.
|
430 | */
|
431 | dive<C2 extends Component, P2 = C2["props"], S2 = C2["state"]>(
|
432 | options?: ShallowRendererProps,
|
433 | ): ShallowWrapper<P2, S2, C2>;
|
434 | dive<P2, S2>(options?: ShallowRendererProps): ShallowWrapper<P2, S2>;
|
435 | dive<P2, S2, C2>(options?: ShallowRendererProps): ShallowWrapper<P2, S2, C2>;
|
436 |
|
437 | /**
|
438 | * Strips out all the not host-nodes from the list of nodes
|
439 | *
|
440 | * This method is useful if you want to check for the presence of host nodes
|
441 | * (actually rendered HTML elements) ignoring the React nodes.
|
442 | */
|
443 | hostNodes(): ShallowWrapper<HTMLAttributes>;
|
444 |
|
445 | /**
|
446 | * Returns a wrapper around all of the parents/ancestors of the wrapper. Does not include the node in the
|
447 | * current wrapper. Optionally, a selector can be provided and it will filter the parents by this selector.
|
448 | *
|
449 | * Note: can only be called on a wrapper of a single node.
|
450 | */
|
451 | parents<P2>(statelessComponent: FunctionComponent<P2>): ShallowWrapper<P2, never>;
|
452 | parents<P2>(component: ComponentType<P2>): ShallowWrapper<P2, any>;
|
453 | parents(selector: string): ShallowWrapper<HTMLAttributes, any>;
|
454 | parents(props?: EnzymePropSelector): ShallowWrapper<any, any>;
|
455 |
|
456 | /**
|
457 | * Returns a wrapper of the first element that matches the selector by traversing up through the current node's
|
458 | * ancestors in the tree, starting with itself.
|
459 | *
|
460 | * Note: can only be called on a wrapper of a single node.
|
461 | */
|
462 | closest<P2>(statelessComponent: FunctionComponent<P2>): ShallowWrapper<P2, never>;
|
463 | closest<P2>(component: ComponentType<P2>): ShallowWrapper<P2, any>;
|
464 | closest(props: EnzymePropSelector): ShallowWrapper<any, any>;
|
465 | closest(selector: string): ShallowWrapper<HTMLAttributes, any>;
|
466 |
|
467 | /**
|
468 | * Returns a wrapper with the direct parent of the node in the current wrapper.
|
469 | */
|
470 | parent(): ShallowWrapper<any, any>;
|
471 |
|
472 | /**
|
473 | * Returns a wrapper of the node rendered by the provided render prop.
|
474 | */
|
475 | renderProp<PropName extends keyof P>(
|
476 | prop: PropName,
|
477 | ): (...params: Parameters<P[PropName]>) => ShallowWrapper<any, never>;
|
478 |
|
479 | /**
|
480 | * If a wrappingComponent was passed in options,
|
481 | * this methods returns a ShallowWrapper around the rendered wrappingComponent.
|
482 | * This ShallowWrapper can be used to update the wrappingComponent's props and state
|
483 | */
|
484 | getWrappingComponent: () => ShallowWrapper;
|
485 | }
|
486 |
|
487 | export interface ReactWrapper<P = {}, S = {}, C = Component> extends CommonWrapper<P, S, C> {}
|
488 | export class ReactWrapper<P = {}, S = {}, C = Component> {
|
489 | constructor(nodes: JSX.Element | JSX.Element[], root?: ReactWrapper<any, any>, options?: MountRendererProps);
|
490 |
|
491 | unmount(): this;
|
492 | mount(): this;
|
493 |
|
494 | /**
|
495 | * Returns a wrapper of the node that matches the provided reference name.
|
496 | *
|
497 | * NOTE: can only be called on a wrapper instance that is also the root instance.
|
498 | */
|
499 | ref(refName: string): ReactWrapper<any, any>;
|
500 | ref<P2, S2>(refName: string): ReactWrapper<P2, S2>;
|
501 |
|
502 | /**
|
503 | * Detaches the react tree from the DOM. Runs ReactDOM.unmountComponentAtNode() under the hood.
|
504 | *
|
505 | * This method will most commonly be used as a "cleanup" method if you decide to use the attachTo option in mount(node, options).
|
506 | *
|
507 | * The method is intentionally not "fluent" (in that it doesn't return this) because you should not be doing anything with this wrapper after this method is called.
|
508 | *
|
509 | * Using the attachTo is not generally recommended unless it is absolutely necessary to test something.
|
510 | * It is your responsibility to clean up after yourself at the end of the test if you do decide to use it, though.
|
511 | */
|
512 | detach(): void;
|
513 |
|
514 | /**
|
515 | * Strips out all the not host-nodes from the list of nodes
|
516 | *
|
517 | * This method is useful if you want to check for the presence of host nodes
|
518 | * (actually rendered HTML elements) ignoring the React nodes.
|
519 | */
|
520 | hostNodes(): ReactWrapper<HTMLAttributes>;
|
521 |
|
522 | /**
|
523 | * Find every node in the render tree that matches the provided selector.
|
524 | * @param selector The selector to match.
|
525 | */
|
526 | find<P2>(statelessComponent: FunctionComponent<P2>): ReactWrapper<P2, never>;
|
527 | find<P2>(component: ComponentType<P2>): ReactWrapper<P2, any>;
|
528 | find<C2 extends Component>(componentClass: ComponentClass<C2["props"]>): ReactWrapper<C2["props"], C2["state"], C2>;
|
529 | find(props: EnzymePropSelector): ReactWrapper<any, any>;
|
530 | find(selector: string): ReactWrapper<HTMLAttributes, any>;
|
531 |
|
532 | /**
|
533 | * Finds every node in the render tree that returns true for the provided predicate function.
|
534 | */
|
535 | findWhere(predicate: (wrapper: ReactWrapper<any, any>) => boolean): ReactWrapper<any, any>;
|
536 |
|
537 | /**
|
538 | * Removes nodes in the current wrapper that do not match the provided selector.
|
539 | * @param selector The selector to match.
|
540 | */
|
541 | filter<P2>(statelessComponent: FunctionComponent<P2>): ReactWrapper<P2, never>;
|
542 | filter<P2>(component: ComponentType<P2>): ReactWrapper<P2, any>;
|
543 | filter(props: EnzymePropSelector | string): ReactWrapper<P, S>;
|
544 |
|
545 | /**
|
546 | * Returns a new wrapper with all of the children of the node(s) in the current wrapper. Optionally, a selector
|
547 | * can be provided and it will filter the children by this selector.
|
548 | */
|
549 | children<P2>(statelessComponent: FunctionComponent<P2>): ReactWrapper<P2, never>;
|
550 | children<P2>(component: ComponentType<P2>): ReactWrapper<P2, any>;
|
551 | children(selector: string): ReactWrapper<HTMLAttributes, any>;
|
552 | children(props?: EnzymePropSelector): ReactWrapper<any, any>;
|
553 |
|
554 | /**
|
555 | * Returns a new wrapper with child at the specified index.
|
556 | */
|
557 | childAt(index: number): ReactWrapper<any, any>;
|
558 | childAt<P2, S2>(index: number): ReactWrapper<P2, S2>;
|
559 |
|
560 | /**
|
561 | * Returns a wrapper around all of the parents/ancestors of the wrapper. Does not include the node in the
|
562 | * current wrapper. Optionally, a selector can be provided and it will filter the parents by this selector.
|
563 | *
|
564 | * Note: can only be called on a wrapper of a single node.
|
565 | */
|
566 | parents<P2>(statelessComponent: FunctionComponent<P2>): ReactWrapper<P2, never>;
|
567 | parents<P2>(component: ComponentType<P2>): ReactWrapper<P2, any>;
|
568 | parents(selector: string): ReactWrapper<HTMLAttributes, any>;
|
569 | parents(props?: EnzymePropSelector): ReactWrapper<any, any>;
|
570 |
|
571 | /**
|
572 | * Returns a wrapper of the first element that matches the selector by traversing up through the current node's
|
573 | * ancestors in the tree, starting with itself.
|
574 | *
|
575 | * Note: can only be called on a wrapper of a single node.
|
576 | */
|
577 | closest<P2>(statelessComponent: FunctionComponent<P2>): ReactWrapper<P2, never>;
|
578 | closest<P2>(component: ComponentType<P2>): ReactWrapper<P2, any>;
|
579 | closest(props: EnzymePropSelector): ReactWrapper<any, any>;
|
580 | closest(selector: string): ReactWrapper<HTMLAttributes, any>;
|
581 |
|
582 | /**
|
583 | * Returns a wrapper with the direct parent of the node in the current wrapper.
|
584 | */
|
585 | parent(): ReactWrapper<any, any>;
|
586 |
|
587 | /**
|
588 | * Returns a wrapper of the node rendered by the provided render prop.
|
589 | */
|
590 | renderProp<PropName extends keyof P>(
|
591 | prop: PropName,
|
592 | ): (...params: Parameters<P[PropName]>) => ReactWrapper<any, never>;
|
593 |
|
594 | /**
|
595 | * If a wrappingComponent was passed in options,
|
596 | * this methods returns a ReactWrapper around the rendered wrappingComponent.
|
597 | * This ReactWrapper can be used to update the wrappingComponent's props and state
|
598 | */
|
599 | getWrappingComponent: () => ReactWrapper;
|
600 | }
|
601 |
|
602 | export interface Lifecycles {
|
603 | componentDidUpdate?: {
|
604 | onSetState: boolean;
|
605 | prevContext: boolean;
|
606 | } | undefined;
|
607 | getDerivedStateFromProps?: { hasShouldComponentUpdateBug: boolean } | boolean | undefined;
|
608 | getChildContext?: {
|
609 | calledByRenderer: boolean;
|
610 | [key: string]: any;
|
611 | } | undefined;
|
612 | setState?: any;
|
613 |
|
614 | [lifecycleName: string]: any;
|
615 | }
|
616 |
|
617 | export interface ShallowRendererProps {
|
618 |
|
619 | |
620 |
|
621 |
|
622 |
|
623 | disableLifecycleMethods?: boolean | undefined;
|
624 | |
625 |
|
626 |
|
627 | lifecycleExperimental?: boolean | undefined;
|
628 | |
629 |
|
630 |
|
631 | context?: any;
|
632 | |
633 |
|
634 |
|
635 |
|
636 | enableComponentDidUpdateOnSetState?: boolean | undefined;
|
637 | |
638 |
|
639 |
|
640 |
|
641 | supportPrevContextArgumentOfComponentDidUpdate?: boolean | undefined;
|
642 | lifecycles?: Lifecycles | undefined;
|
643 | |
644 |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 | wrappingComponent?: ComponentType<any> | undefined;
|
650 | |
651 |
|
652 |
|
653 | wrappingComponentProps?: {} | undefined;
|
654 | |
655 |
|
656 |
|
657 |
|
658 |
|
659 | suspenseFallback?: boolean | undefined;
|
660 | adapter?: EnzymeAdapter | undefined;
|
661 |
|
662 | attachTo?: any;
|
663 | hydrateIn?: any;
|
664 | PROVIDER_VALUES?: any;
|
665 | }
|
666 |
|
667 | export interface MountRendererProps {
|
668 | |
669 |
|
670 |
|
671 | context?: {} | undefined;
|
672 | |
673 |
|
674 |
|
675 | attachTo?: HTMLElement | null | undefined;
|
676 | |
677 |
|
678 |
|
679 | childContextTypes?: {} | undefined;
|
680 | |
681 |
|
682 |
|
683 |
|
684 |
|
685 |
|
686 | wrappingComponent?: ComponentType<any> | undefined;
|
687 | |
688 |
|
689 |
|
690 | wrappingComponentProps?: {} | undefined;
|
691 | }
|
692 |
|
693 |
|
694 |
|
695 |
|
696 |
|
697 | export function shallow<C extends Component, P = C["props"], S = C["state"]>(
|
698 | node: ReactElement<P>,
|
699 | options?: ShallowRendererProps,
|
700 | ): ShallowWrapper<P, S, C>;
|
701 | export function shallow<P>(node: ReactElement<P>, options?: ShallowRendererProps): ShallowWrapper<P, any>;
|
702 | export function shallow<P, S>(node: ReactElement<P>, options?: ShallowRendererProps): ShallowWrapper<P, S>;
|
703 |
|
704 |
|
705 |
|
706 |
|
707 | export function mount<C extends Component, P = C["props"], S = C["state"]>(
|
708 | node: ReactElement<P>,
|
709 | options?: MountRendererProps,
|
710 | ): ReactWrapper<P, S, C>;
|
711 | export function mount<P>(node: ReactElement<P>, options?: MountRendererProps): ReactWrapper<P, any>;
|
712 | export function mount<P, S>(node: ReactElement<P>, options?: MountRendererProps): ReactWrapper<P, S>;
|
713 |
|
714 |
|
715 |
|
716 |
|
717 | export function render<P, S>(node: ReactElement<P>, options?: any): cheerio.Cheerio;
|
718 |
|
719 |
|
720 | export class EnzymeAdapter {
|
721 | wrapWithWrappingComponent?: ((node: ReactElement, options?: ShallowRendererProps) => any) | undefined;
|
722 | }
|
723 |
|
724 | /**
|
725 | * Configure enzyme to use the correct adapter for the react version
|
726 | * This is enabling the Enzyme configuration with adapters in TS
|
727 | */
|
728 | export function configure(options: {
|
729 | adapter: EnzymeAdapter;
|
730 |
|
731 |
|
732 |
|
733 | |
734 |
|
735 |
|
736 |
|
737 | disableLifecycleMethods?: boolean | undefined;
|
738 | }): void;
|
739 |
|
\ | No newline at end of file |