Created
June 24, 2022 22:20
-
-
Save pushkar100/e80f3f385989d80e4803c4c6bd58f16a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* src/__tests__/helpers/index.test.js */ | |
import { isEarlierThanNow, fetchFakeAPIData } from '../../helpers'; | |
// ... | |
test('fetchFakeAPIData, when requesting an animal, responds with a dog', (done) => { | |
// Arrange | |
const testRequest = { animal: true }; | |
// Act | |
fetchFakeAPIData(testRequest).then(({ animal, name }) => { | |
// Assert | |
expect(animal).toBe('Dog'); | |
expect(name).toBe('Charlie'); | |
done(); | |
}) | |
}); | |
test('fetchFakeAPIData, when not requesting an animal, responds with an error message', (done) => { | |
// Arrange | |
const testRequest = { random: true }; | |
// Act | |
fetchFakeAPIData(testRequest).catch(({ error }) => { | |
// Assert | |
expect(error).toMatch(/Did not find species/i); | |
done(); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment