[@types/enzyme] Add missing Wrapper debug options parameter (#36604)

* [@types/enzyme] add missing wrapper debug options

* [@types/enzyme] add wrapper debug tests

* lint

* add name to definitions

* chore: format comments to be intellisense-friendly

* chore: remove newline
This commit is contained in:
Erick Zhao
2019-07-09 16:27:00 -07:00
committed by Armando Aguirre
parent 87bc03b812
commit d83339fdaa
2 changed files with 22 additions and 4 deletions
+6
View File
@@ -456,6 +456,9 @@ function ShallowWrapperTest() {
function test_debug() {
stringVal = shallowWrapper.debug();
stringVal = shallowWrapper.debug({ verbose: false });
stringVal = shallowWrapper.debug({ ignoreProps: true });
stringVal = shallowWrapper.debug({ ignoreProps: true, verbose: true });
}
function test_type() {
@@ -885,6 +888,9 @@ function ReactWrapperTest() {
function test_debug() {
stringVal = reactWrapper.debug();
stringVal = reactWrapper.debug({ verbose: false });
stringVal = reactWrapper.debug({ ignoreProps: true });
stringVal = reactWrapper.debug({ ignoreProps: true, verbose: true });
}
function test_type() {
+16 -4
View File
@@ -11,6 +11,7 @@
// Christian Rackerseder <https://github.com/screendriver>
// Mateusz Sokoła <https://github.com/mateuszsokola>
// Braiden Cutforth <https://github.com/braidencutforth>
// Erick Zhao <https://github.com/erickzhao>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.1
@@ -102,9 +103,15 @@ export interface CommonWrapper<P = {}, S = {}, C = Component<P, S>> {
* @param ...args The argments to the invokePropName function
* @returns The value of the function.
*/
invoke<K extends NonNullable<{
[K in keyof P]: P[K] extends ((...arg: any[]) => void) | undefined ? K : never
}[keyof P]>>(invokePropName: K): P[K];
invoke<
K extends NonNullable<
{
[K in keyof P]: P[K] extends ((...arg: any[]) => void) | undefined ? K : never;
}[keyof P]
>
>(
invokePropName: K
): P[K];
/**
* Returns whether or not the current node matches a provided selector.
@@ -300,7 +307,12 @@ export interface CommonWrapper<P = {}, S = {}, C = Component<P, S>> {
* Returns an html-like string of the wrapper for debugging purposes. Useful to print out to the console when
* tests are not passing when you expect them to.
*/
debug(): string;
debug(options?: {
/** Whether props should be omitted in the resulting string. Props are included by default. */
ignoreProps?: boolean;
/** Whether arrays and objects passed as props should be verbosely printed. */
verbose?: boolean;
}): string;
/**
* Returns the name of the current node of the wrapper.