Within my component, I have the following method:
methods:{
ContactUs(){
this.$http.post("/api/contact-us").then((res)=>{
///do new stuff
},(err)=>{
//do new stuff
})
},
}
Now, I am trying to test if the method functions correctly.
In my test script, I implemented the following:
const wrapper = mount(ContactForm);
it("Contact us method should return a 200 response ", () => {
wrapper.vm.ContactUs().then((res) => {
expect(res.data).toEqual(res);
})
//await flushPromises();
});
However, the test is failing and the error seems to be related to the 'this.$http.post' line...
How should I go about properly testing the above function?