Last active
June 24, 2022 21:51
-
-
Save pushkar100/9b7a6482e3af0a4176c8b6e01a4b26e5 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', () => { | |
// Arrange | |
const testRequest = { animal: true }; | |
// Act | |
return fetchFakeAPIData(testRequest).then(({ animal, name }) => { | |
// Assert | |
expect(animal).toBe('Dog'); | |
expect(name).toBe('Charlie'); | |
}) | |
}); | |
test('fetchFakeAPIData, when not requesting an animal, responds with an error message', () => { | |
// Arrange | |
const testRequest = { random: true }; | |
// Act | |
return fetchFakeAPIData(testRequest).catch(({ error }) => { | |
// Assert | |
expect(error).toMatch(/Did not find species/i); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment