React hooks unit testing React.memo on a function

88 Views Asked by At

How can I test this function wrapped in the React.memo , below is the function :

    const InternalDocuments = memo(
      forwardRef<FormikProps<BlocksTypes>, InternalDocumentsProps>(
        (
          {
            documentBlocks,
            loanId,
            updateZins,
            mainSetFieldValue,
            completedFieldRequiredRLA2,
            documentData,
          },
          formikRef,
        ) => {
          const [blocks, setBlocks] = useState<BlockBackend[]>([]);
          const classes = useStyles();
          const { setBalanceSheetValues, setBalanceSchufaValues } = useContext(DataContext);
    
          const mapDocumentBlocks = useCallback(
            () =>
             ...
            [],
          );
    
          const updateDataField = useCallback(
            (levels: indexObj, value: string, id: number) => {
             ....
            },
            [blocks],
          );
    
          useEffect(() => {
          }, []);
    
          return (
           <div>...</div>
          );
        },
      ),
    );
export default InternalDocuments;

This is my test below :

 it('should map document blocks', () =>{
    const { result } = renderHook(() => InternalDocuments())
    expect(typeof result.current.updateDataField).toBe('function')
  })

But I get this error :

 TypeError: (0 , _InternalDocuments.default) is not a function
0

There are 0 best solutions below