如何检查儿童用酶和摩卡咖啡传递给反应成分的是什么?

时间:2016-03-23 11:39:32

标签: reactjs enzyme

我们说我有以下组件实例:

<ParentComponentWhichIsTested>
    <Expand trigger={<span>Click me to expand this element</span>}>
        <ComponentReference1></ComponentReference1>
    </Expand>

    <Expand trigger={<span>Click me to expand this element</span>}>
        <ComponentReference2></ComponentReference1>
    </Expand> 
</ParentComponentWhichIsTested>

Expand的渲染方法如下所示:

//in expand
render () {
    return (
        <div>
            <ExpandTrigger>{trigger}</ExpandTrigger>
            <ExpandContent>{this.props.children}</ExpandContent>
        </div>
    );

}

我想断言第一个Expand实例的内容组件类型为ComponentReference1,第二个实例的内容组件类型为ComponentReference2

import { mount } from 'enzyme';

const comp = mount(...ParentComponentWhichIsTested...)
console.log(comp.props().children); //will be 2, the trigger and content nodes, but I want to see that I actually *sent* a child, not what the component rendered. 

如何查看寄孩子?难道我做错了什么?

提前致谢!

0 个答案:

没有答案