I have an onCompleted that I am trying to test from my useMutation, I am using jest and react-testing-library. This is the piece of code I am trying to test
this is my react code:
const [deleteJobs] = useMutation<DeleteJobsMutation, MutationDeleteJobsArgs>(
mutationQuery,
{
refetchQueries: refetchQueries as string[],
onCompleted: () => (callback ? callback() : onCancel?.(null)),
},)
my mutation:
mutation deleteJobs($jobIds: [ID!]!) { deleteJobs(jobIds: $jobIds) {
successful}}
I have managed to mock it so it does call and I have also mocked it to succeed so I can test scenarios on success but I can't seem to work out how to get it to trigger the onCompleted
Apollo Client's test suite has an example that demonstrates how to mock and test
useMutation
'sonCompleted
callback: