Skip to content

Instantly share code, notes, and snippets.

@bmfteixeira
Last active September 18, 2017 18:49
Show Gist options
  • Save bmfteixeira/21c25b61cd21aabec3d51166c9e54bbd to your computer and use it in GitHub Desktop.
Save bmfteixeira/21c25b61cd21aabec3d51166c9e54bbd to your computer and use it in GitHub Desktop.
describe('Basic component', () => {
describe('Lifecycle', () => {
it('Mounted', done => {
const handleScrollStub = sinon.stub(BasicComponent.methods, 'handleScroll')
const addEventStub = sinon.stub(window, 'addEventListener')
const wrapper = mount(BasicComponent)
expect(addEventStub).to.be.calledWith('scroll', wrapper.vm.handleScroll)
handleScrollStub.restore()
addEventStub.restore()
done()
})
it('Destroyed', done => {
const wrapper = mount(BasicComponent)
const handleScrollStub = sinon.stub(wrapper.vm, 'handleScroll')
const removeEventStub = sinon.stub(window, 'removeEventListener')
wrapper.destroy()
expect(removeEventStub).to.be.calledWith('scroll', wrapper.vm.handleScroll)
handleScrollStub.restore()
removeEventStub.restore()
done()
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment