我有一个redux表单字段数组:
doReturn
我正在尝试测试此组件并检查它是否正确呈现。我正在使用public static Stubber doReturn(Object toBeReturned)
public static Stubber doReturn(Object toBeReturned, Object... toBeReturnedNext)
模拟该export const UttakPeriod = ({
fields,
updatePeriode,
editPeriode,
cancelEditPeriode,
isAnyFormOpen,
isNyPeriodeFormOpen,
readOnly,
periods,
...other
}) => (
<div>
{fields.map((fieldId, index, field) => {
const period = field.get(index);
return (
<div key={fieldId}>
{other.meta.error && index === 0 ? <AlertStripe type="warning">{other.meta.error}</AlertStripe> : null}
<Row>
<Column>
<UttakPeriodType
toDate={period.tom}
fromDate={period.fom}
openForm={periode.openForm}
id={period.id}
editPeriode={editPeriode}
isAnyFormOpen={isAnyFormOpen}
isNyPeriodeFormOpen={isNyPeriodeFormOpen}
readOnly={readOnly}
/>
<UttakPeriodContent
fieldId={fieldId}
openForm={period.openForm}
id={period.id}
updatePeriode={updatePeriode}
cancelEditPeriode={cancelEditPeriode}
readOnly={readOnly}
toDate={period.tom}
fromDate={period.fom}
/>
</Column>
</Row>
</div>
);
})}
</div>
);
组件的字段。这是测试:
getMockedFields
但是,我在这个测试中遇到错误:
AssertionError:期望{length:0}的长度为2,但得到0
为什么此测试失败,我该如何解决?