Skip to content

Instantly share code, notes, and snippets.

@bmfteixeira
Last active October 7, 2017 16:08
Show Gist options
  • Save bmfteixeira/a7aac84240c27800db891efb606c485b to your computer and use it in GitHub Desktop.
Save bmfteixeira/a7aac84240c27800db891efb606c485b to your computer and use it in GitHub Desktop.
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