Last active
September 11, 2018 12:56
-
-
Save kuroski/adc63ee55903da0a3e868f36dc04ab9c 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
import flushPromises from 'flush-promises' | |
import nock from 'nock' | |
import api from '@/api' | |
import userFixture from './fixtures/user' | |
describe('api', () => { | |
it('searches for the user', async () => { | |
// arrange | |
const expectedUser = 'kuroski' | |
const request = nock('https://api.github.com') | |
.get(`/users/${expectedUser}`) | |
.reply(200, userFixture) | |
// act | |
const result = await api.searchUser(expectedUser) | |
await flushPromises() | |
// assert | |
expect(result).toEqual(userFixture) | |
expect(request.isDone()).toBe(true) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment