【发布时间】:2016-12-19 00:55:52
【问题描述】:
我正在测试一个有 5 个链接的反应组件。每个链接都根据当前路由激活。我正在使用 Meteor 和 Mantra 和酶来测试这些组件。
页脚组件:
import React from 'react';
class Footer extends React.Component{
render(){
let route = FlowRouter.current().route.name;
return(
<a className={route == 'hub page' ? 'some-class active' : 'some-class'}> . . . (x5)
)
}
}
测试
describe {shallow} from 'enzyme';
import Footer from '../core/components/footer';
describe('footer',() => {
it('should have 5 links', () => {
const fooWrapper = shallow(<Footer/>);
expect(fooWrapper.find('a')).to.have.length(5);
})
})
但是当我运行npm test 时,它说FlowRouter is not defined. 如何在测试中将FlowRouter 上下文传递给反应组件?提前致谢
【问题讨论】:
标签: meteor reactjs flow-router enzyme mantrajs