Skip to content

Instantly share code, notes, and snippets.

@bmfteixeira
Last active October 16, 2017 10:44
Show Gist options
  • Save bmfteixeira/a6ea2cd7d47f154edee92628b9721ac1 to your computer and use it in GitHub Desktop.
Save bmfteixeira/a6ea2cd7d47f154edee92628b9721ac1 to your computer and use it in GitHub Desktop.
import { GET_OBJECTS } from 'services/constants/action-types'
describe('Objects component', () => {
let store
let state
let actions
beforeEach(() => {
actions = {}
actions[GET_OBJECTS] = sinon.stub()
state = {
modules: {
// mock state, with actions and getters if any
objects: {
namespaced: true,
state: {
objs: []
},
actions
}
}
}
store = new Vuex.Store(state)
})
describe('Methods', () => {
it('getObjects - should set data.currentObjects with response returned from getObjects', done => {
const mockedObjects = [
{ id: 1 },
{ id: 2 }
]
const wrapper = shallow(ObjectsComponent, {
store
})
const getObjectsStub = sinon.stub(wrapper.vm, 'getObjects').returns(mockedObjects)
wrapper.vm.getObjects()
.then((result) => {
expect(result).to.be.true
expect(wrapper.data().currentObjects).to.be.deep.equal(mockedObjects)
getObjectsStub.restore()
done()
})
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment