-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit tests for GraphQLClient #15
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - Fantastic start @jackdclark 👍
test/unit/GraphQLClient.test.js
Outdated
}); | ||
|
||
it('assigns config.logErrors to an instance property', () => { | ||
const logErrors = jest.fn(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: logErrors
should be a Boolean
test/unit/GraphQLClient.test.js
Outdated
const client = new GraphQLClient({ ...validConfig }); | ||
fetch.mockResponseOnce(JSON.stringify({ data: 'data' })); | ||
await client.request({ query: TEST_QUERY }); | ||
expect(fetch.mock.calls[0][0]).toBe(validConfig.url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: Sometimes it's useful to set actual
and expected
explicitly, making it a bit clearer to understand whats being tested:
const actual = fetch.mock.calls[0][0]
const expected = validConfig.url
expect(actual).toBe(expected)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Part of #9
Add test coverage for
GraphQLClient