I am facing an issue with a Vue login component failing a test:
LoginForm should emit submit event
Error:
submit event should be emitted when submitting form
expect(jest.fn()).toHaveBeenCalled()
Expected number of calls: >= 1
Received number of calls: 0
Button:
<button type="button" id="login-button" :disabled="!enableSubmit" @click="submit()">Submit</button>
Methods:
submit() {
if(this.username != "" && this.password != "") {
this.$emit("You have successfully loged in", this.username && this.password)
} else {
console.log("Not logged in")
}
}
Can someone guide me on how to correctly emit the submit event?