使用Mocha酶测试React功能组件中的功能

时间:2020-02-19 02:21:55

标签: reactjs functional-programming components mocha enzyme

我在网上找到的用于使用Mocha和Enzyme测试React组件的大多数指南都是针对类组件的。对于功能组件,我不确定如何测试其中的功能:

function Student(props) {
    function formatStudentName(unformattedName) {
        //does something to format name
        return formattedName;
    }
  
  
}

export default Student;

例如,如果我想编写一个单元测试来测试功能 formatStudentName ,该如何调用该功能?

0 个答案:

没有答案