-
-
Save devotdev/41b1502656435a64c0eadd6461748bf0 to your computer and use it in GitHub Desktop.
Using done callback for complex async code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('fetches data using done callback', (done) => { | |
const data = { id: 1, name: 'John Doe' }; | |
axios.get.mockResolvedValue({ data }); | |
fetchData('https://api.example.com/user/1').then(result => { | |
expect(result).toEqual(data); | |
done(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment