Skip to content

Instantly share code, notes, and snippets.

@kuroski
Last active September 11, 2018 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuroski/adc63ee55903da0a3e868f36dc04ab9c to your computer and use it in GitHub Desktop.
Save kuroski/adc63ee55903da0a3e868f36dc04ab9c to your computer and use it in GitHub Desktop.
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