Last active
October 7, 2017 16:08
-
-
Save bmfteixeira/a7aac84240c27800db891efb606c485b 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
describe('Objects component', () => { | |
describe('Methods', () => { | |
it('getObjects - should return true and set the data.currentObjects if getObjects retrieves an array of objects', done => { | |
const mockedObjects = [ | |
{ id: 1 }, | |
{ id: 2 } | |
] | |
const wrapper = mount(ObjectsComponent) | |
const getObjectsStub = sinon.stub(wrapper.vm, 'getObjects').returns(mockedObjects) | |
const result = wrapper.vm.getObjects() | |
expect(result).to.be.true | |
expect(wrapper.data().currentObjects).to.be.deep.equal(mockedObjects) | |
getObjectsStub.restore() | |
done() | |
}) | |
it('getObjects - should return false and set the data.hasError to true if getObjects retrieves an empty array', done => { | |
const mockedObjects = [] | |
const wrapper = mount(ObjectsComponent) | |
const getObjectsStub = sinon.stub(wrapper.vm, 'getObjects').returns(mockedObjects) | |
const result = wrapper.vm.getObjects() | |
expect(result).to.be.false | |
expect(wrapper.data().hasError).to.be.true | |
getObjectsStub.restore() | |
done() | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment