mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
Add tests for to-top-button.vue
This commit is contained in:
parent
5ca8d90a82
commit
ff37d7aaaf
2 changed files with 13 additions and 1 deletions
|
@ -27,7 +27,7 @@ export default {
|
|||
},
|
||||
|
||||
mounted () {
|
||||
this.$el.parentNode.addEventListener('scroll', e => {
|
||||
this.$el.parentNode && this.$el.parentNode.addEventListener('scroll', e => {
|
||||
this.showing = e.target.scrollTop > 64
|
||||
})
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
import Component from '@/components/shared/to-top-button.vue'
|
||||
import { $ } from '@/utils'
|
||||
|
||||
describe('components/shared/to-top-button', () => {
|
||||
it('scrolls to top', () => {
|
||||
const scrollToStub = sinon.stub($, 'scrollTo')
|
||||
const wrapper = shallow(Component)
|
||||
wrapper.find('button').trigger('click')
|
||||
scrollToStub.called.should.be.true
|
||||
scrollToStub.restore()
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue