I am currently writing a unit test for my selector. Which would take in nested arrays and return a single array. I am using .flat() operator for this. For some reason I get this error:

TypeError: contactInfoSelection.flat is not a function

Please find below my selector and my current unit test case. Any suggestions on how to approach it would be great!

export const getSingledArray = createSelector(
getContactInfoSelection,
(contactInfoSelection) => {
return contactInfoSelection.flat(); 
}
);

//test case

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'])});
  });

0 Answers