fix enzyme CommonWrapper.reduce function to return R instead of R[] (#13763)

This commit is contained in:
Ben Katz
2017-01-05 22:02:09 +02:00
committed by Andy
parent 694b16f5b0
commit ce5eb0cc2c
2 changed files with 8 additions and 8 deletions

View File

@@ -277,14 +277,14 @@ namespace ShallowWrapperTest {
}
function test_reduce() {
const total: number[] =
const total: number =
shallowWrapper.reduce(
(amount: number, n: ShallowWrapper<MyComponentProps, MyComponentState>) => amount + n.props().numberProp
);
}
function test_reduceRight() {
const total: number[] =
const total: number =
shallowWrapper.reduceRight<number>(
(amount: number, n: ShallowWrapper<MyComponentProps, MyComponentState>) => amount + n.prop('amount')
);
@@ -557,14 +557,14 @@ namespace ReactWrapperTest {
}
function test_reduce() {
const total: number[] =
const total: number =
reactWrapper.reduce<number>(
(amount: number, n: ReactWrapper<MyComponentProps, MyComponentState>) => amount + n.prop('amount')
);
}
function test_reduceRight() {
const total: number[] =
const total: number =
reactWrapper.reduceRight<number>(
(amount: number, n: ReactWrapper<MyComponentProps, MyComponentState>) => amount + n.prop('amount')
);
@@ -799,14 +799,14 @@ namespace CheerioWrapperTest {
}
function test_reduce() {
const total: number[] =
const total: number =
cheerioWrapper.reduce<number>(
(amount: number, n: CheerioWrapper<MyComponentProps, MyComponentState>) => amount + n.prop('amount')
);
}
function test_reduceRight() {
const total: number[] =
const total: number =
cheerioWrapper.reduceRight<number>(
(amount: number, n: CheerioWrapper<MyComponentProps, MyComponentState>) => amount + n.prop('amount')
);

4
enzyme/index.d.ts vendored
View File

@@ -346,7 +346,7 @@ interface CommonWrapper<P, S> {
* @param fn
* @param initialValue
*/
reduce<R>(fn: (prevVal: R, wrapper: this, index: number) => R, initialValue?: R): R[];
reduce<R>(fn: (prevVal: R, wrapper: this, index: number) => R, initialValue?: R): R;
/**
* Applies the provided reducing function to every node in the wrapper to reduce to a single value.
@@ -354,7 +354,7 @@ interface CommonWrapper<P, S> {
* @param fn
* @param initialValue
*/
reduceRight<R>(fn: (prevVal: R, wrapper: this, index: number) => R, initialValue?: R): R[];
reduceRight<R>(fn: (prevVal: R, wrapper: this, index: number) => R, initialValue?: R): R;
/**
* Returns whether or not any of the nodes in the wrapper match the provided selector.