我目前正在为选择器编写单元测试。这将采用嵌套数组并返回单个数组。我为此使用.flat()运算符。由于某种原因,我收到此错误:
TypeError:contactInfoSelection.flat不是函数
请在我的选择器和当前的单元测试用例下面找到。关于如何处理它的任何建议都很棒!
export const getSingledArray = createSelector(
getContactInfoSelection,
(contactInfoSelection) => {
return contactInfoSelection.flat();
}
);
//测试用例
it('should return singled array from nested arrays', () => {
store.dispatch(new ContactInfoSelectionSucceeded(getContactInfoSelectionMock()));
store
.pipe(select(contactInfoSelection))
.subscribe((contentInfo:any) => {expect(contentInfo).toEqual(
['TAXES', 'RETIREMENT','RMD', 'PARTICIPANT','VOYAGER', 'ADVISOR','TECHNICAL_SUPPORT'])});
});