0
我有以下情况:阵营 - 单元测试与设定功能
describe('API - Input component',() => {
describe('Input element',() => {
it('should have a modifier to its class if data entered is erroneous',() => {
const wrapper = shallow(<Input error="Invalid data" />);
expect(wrapper.find('input').props().className).toBe('form-field__input form-field__input--error');
});
});
});
这工作完全正常。只要我将一些数据传递给我的错误道具,应该预期修改器类并通过测试。
现在,我想实现同样的事情,但使用设置功能。像这样:
function setup() {
const props = {
error: {}
};
return shallow(<Input {...props} />);
}
describe('API - Input component',() => {
describe('Input element',() => {
it('should have a modifier to its class if data entered is erroneous',() => {
const wrapper = setup(how do I pass my props here?!);
expect(wrapper.find('input').props().className).toBe('form-field__input form-field__input--error');
});
});
});
谢谢!
非常感谢! – Manu
欢迎 –