Last active
October 16, 2017 10:44
-
-
Save bmfteixeira/a6ea2cd7d47f154edee92628b9721ac1 to your computer and use it in GitHub Desktop.
This file contains 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 { 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