Skip to content

Commit

Permalink
Update src-clean folder fix #56
Browse files Browse the repository at this point in the history
  • Loading branch information
diegohaz committed Jan 19, 2017
1 parent cf0b2a1 commit 270e4a7
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src-clean/services/api/index.test.js
@@ -1,33 +1,31 @@
import axios from 'axios'
import { stub, spy } from 'sinon'

const request = spy()

stub(axios, 'create', () => ({ request }))
const request = jest.fn()
axios.create = jest.fn(() => ({ request }))

const api = require('.').default

beforeEach(() => {
request.reset()
request.mockClear()
})

test('get', () => {
expect(request.called).toBe(false)
expect(request).not.toBeCalled()
api.get('/test', { foo: 'bar' })
expect(request.calledWith({
expect(request).toBeCalledWith({
method: 'get',
url: '/test',
foo: 'bar'
})).toBe(true)
})
})

test('post', () => {
expect(request.called).toBe(false)
expect(request).not.toBeCalled()
api.post('/test', { title: 'test' }, { foo: 'bar' })
expect(request.calledWith({
expect(request).toBeCalledWith({
method: 'post',
url: '/test',
foo: 'bar',
data: { title: 'test' }
})).toBe(true)
})
})

0 comments on commit 270e4a7

Please sign in to comment.