Skip to content

Instantly share code, notes, and snippets.

@curtiswilkinson
Last active February 9, 2017 23:15
Show Gist options
  • Save curtiswilkinson/07033b59fd355231f40b7dd329bc9a19 to your computer and use it in GitHub Desktop.
Save curtiswilkinson/07033b59fd355231f40b7dd329bc9a19 to your computer and use it in GitHub Desktop.
Testing
import * as sut from './index1'
import * as sinon from 'sinon'
import { expect } from 'chai'
describe('_saveAndProcessPayload', () => {
it('will return a formatted API payload', () => {
const mockPayload = [
{ name: 'name1', value: 'value1' },
{ name: 'name2', value: 'value2' },
]
const apiStub = { save: sinon.stub().returns(mockPayload) }
const result = sut._saveAndProcessReturn(apiStub, 'testPayload')
const expected = [
{ name1: 'value1' },
{ name2: 'value2' }
]
expect(result).to.deep.equal(expected)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment