模拟Jest中的按钮单击后如何测试表单是否为空?

时间:2020-09-24 12:16:11

标签: reactjs jestjs enzyme

基本上我正在填写表格,我想检查

test("All fields have information before the submit button is clicked", ()=>{
const wrapper = setup();
const submit = findByTestAttr(wrapper,"submit-button");

submit.simulate('click');

expect(wrapper.state("Date")).not.toBe("");
expect(wrapper.state("Number")).not.toBe("");
expect(wrapper.state("Sign")).not.toBe("");
expect(wrapper.state("test")).not.toBe("test");
expect(wrapper.state("airframe")).not.toBe("airframe");
expect(wrapper.state("Residence")).not.toBe("location");
expect(wrapper.state("destination")).not.toBe("location");

});

0 个答案:

没有答案