mirror of
https://github.com/koel/koel
synced 2024-11-10 14:44:13 +00:00
Replace spies with stubs
This commit is contained in:
parent
516adb6110
commit
95c7953e8f
15 changed files with 37 additions and 32 deletions
|
@ -21,6 +21,7 @@ import viewModeSwitch from '@/components/shared/view-mode-switch.vue'
|
|||
import infiniteScroll from '@/mixins/infinite-scroll'
|
||||
|
||||
export default {
|
||||
name: 'main-wrapper--main-content--albums',
|
||||
mixins: [infiniteScroll],
|
||||
components: { albumItem, viewModeSwitch },
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import viewModeSwitch from '@/components/shared/view-mode-switch.vue'
|
|||
import infiniteScroll from '@/mixins/infinite-scroll'
|
||||
|
||||
export default {
|
||||
name: 'main-wrapper--main-content--artists',
|
||||
mixins: [infiniteScroll],
|
||||
components: { artistItem, viewModeSwitch },
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ import artistItem from '@/components/shared/artist-item.vue'
|
|||
import songItem from '@/components/shared/home-song-item.vue'
|
||||
|
||||
export default {
|
||||
name: 'main-wrapper--main-content--home',
|
||||
components: { albumItem, artistItem, songItem },
|
||||
/**
|
||||
* Note: We're not really using infinite scrolling here,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<section id="mainContent">
|
||||
<div class="translucent" :style="{ backgroundImage: albumCover ? 'url('+albumCover+')' : 'none' }"></div>
|
||||
<div class="translucent" :style="{ backgroundImage: albumCover ? `url${albumCover}` : 'none' }"></div>
|
||||
<home v-show="view === 'home'"/>
|
||||
<queue v-show="view === 'queue'"/>
|
||||
<songs v-show="view === 'songs'"/>
|
||||
|
@ -43,9 +43,7 @@ export default {
|
|||
return {
|
||||
view: 'home', // The default view
|
||||
albumCover: null,
|
||||
sharedState: sharedStore.state,
|
||||
albums: [],
|
||||
artists: []
|
||||
sharedState: sharedStore.state
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -116,6 +116,8 @@ import { forceReloadWindow, $ } from '@/utils'
|
|||
import { http, ls } from '@/services'
|
||||
|
||||
export default {
|
||||
name: 'main-wrapper--main-content--profile',
|
||||
|
||||
data () {
|
||||
return {
|
||||
state: userStore.state,
|
||||
|
|
|
@ -29,6 +29,8 @@ import { parseValidationError, forceReloadWindow, showOverlay, hideOverlay, aler
|
|||
import router from '@/router'
|
||||
|
||||
export default {
|
||||
name: 'main-wrapper--main-content--settings',
|
||||
|
||||
data () {
|
||||
return {
|
||||
state: settingStore.state,
|
||||
|
|
|
@ -34,6 +34,7 @@ import editUserForm from '@/components/modals/edit-user-form.vue'
|
|||
import addUserForm from '@/components/modals/add-user-form.vue'
|
||||
|
||||
export default {
|
||||
name: 'main-wrapper--main-content--users',
|
||||
components: { userItem, editUserForm, addUserForm },
|
||||
|
||||
data () {
|
||||
|
|
|
@ -54,7 +54,6 @@ export const download = {
|
|||
*/
|
||||
fromFavorites () {
|
||||
if (!favoriteStore.all.length) {
|
||||
console.warn("You don't like any song? Come on, don't be that grumpy.")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -6,10 +6,10 @@ describe('components/auth/login-form', () => {
|
|||
})
|
||||
|
||||
it('triggers login method when form is submitted', () => {
|
||||
const spy = sinon.spy()
|
||||
const wrapper = shallow(LoginForm)
|
||||
wrapper.vm.login = spy
|
||||
const loginStub = sinon.stub()
|
||||
wrapper.vm.login = loginStub
|
||||
wrapper.find('form').trigger('submit')
|
||||
spy.called.should.be.true
|
||||
loginStub.called.should.be.true
|
||||
})
|
||||
})
|
||||
|
|
|
@ -43,11 +43,11 @@ describe('components/main-wrapper/extra/index', () => {
|
|||
})
|
||||
|
||||
it('fetch song info when a new song is played', () => {
|
||||
const spy = sinon.spy()
|
||||
const wrapper = shallow(ExtraSidebar)
|
||||
const fetchSongInfoStub = sinon.stub()
|
||||
const song = factory('song')
|
||||
wrapper.vm.fetchSongInfo = spy
|
||||
wrapper.vm.fetchSongInfo = fetchSongInfoStub
|
||||
event.emit('song:played', song)
|
||||
spy.calledWith(song).should.be.true
|
||||
fetchSongInfoStub.calledWith(song).should.be.true
|
||||
})
|
||||
})
|
||||
|
|
|
@ -19,9 +19,9 @@ describe('components/main-wrapper/extra/youtube', () => {
|
|||
})
|
||||
|
||||
it('loads more videos on demand', () => {
|
||||
const spy = sinon.spy()
|
||||
wrapper.vm.loadMore = spy
|
||||
const loadMoreStub = sinon.stub()
|
||||
wrapper.vm.loadMore = loadMoreStub
|
||||
wrapper.find('button.more').trigger('click')
|
||||
spy.should.have.been.called
|
||||
loadMoreStub.should.have.been.called
|
||||
})
|
||||
})
|
||||
|
|
|
@ -25,10 +25,10 @@ describe('components/main-wrapper/main-content/album', () => {
|
|||
album: factory('album'),
|
||||
sharedState: { useLastfm: true }
|
||||
})
|
||||
const spy = sinon.spy()
|
||||
wrapper.showInfo = spy
|
||||
const showInfoStub = sinon.stub()
|
||||
wrapper.showInfo = showInfoStub
|
||||
wrapper.find('a.info').trigger('click')
|
||||
spy.should.have.been.called
|
||||
showInfoStub.should.have.been.called
|
||||
})
|
||||
|
||||
it('allows downloading', () => {
|
||||
|
@ -37,9 +37,9 @@ describe('components/main-wrapper/main-content/album', () => {
|
|||
album: factory('album'),
|
||||
sharedState: { allowDownload: true }
|
||||
})
|
||||
const spy = sinon.spy()
|
||||
wrapper.download = spy
|
||||
const downloadStub = sinon.stub()
|
||||
wrapper.download = downloadStub
|
||||
wrapper.find('a.download').trigger('click')
|
||||
spy.should.have.been.called
|
||||
downloadStub.should.have.been.called
|
||||
})
|
||||
})
|
||||
|
|
|
@ -40,10 +40,10 @@ describe('components/main-wrapper/main-content/artist', () => {
|
|||
artist,
|
||||
sharedState: { useLastfm: true }
|
||||
})
|
||||
const spy = sinon.spy()
|
||||
wrapper.showInfo = spy
|
||||
const showInfoStub = sinon.stub()
|
||||
wrapper.showInfo = showInfoStub
|
||||
wrapper.find('a.info').trigger('click')
|
||||
spy.should.have.been.called
|
||||
showInfoStub.should.have.been.called
|
||||
})
|
||||
|
||||
it('allows downloading', () => {
|
||||
|
@ -52,10 +52,10 @@ describe('components/main-wrapper/main-content/artist', () => {
|
|||
artist,
|
||||
sharedState: { allowDownload: true }
|
||||
})
|
||||
const spy = sinon.spy()
|
||||
wrapper.download = spy
|
||||
const downloadStub = sinon.stub()
|
||||
wrapper.download = downloadStub
|
||||
wrapper.find('a.download').trigger('click')
|
||||
spy.should.have.been.called
|
||||
downloadStub.should.have.been.called
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@ describe('components/main-wrapper/main-content/favorites', () => {
|
|||
},
|
||||
sharedState: { allowDownload: true }
|
||||
})
|
||||
const spy = sinon.spy()
|
||||
wrapper.download = spy
|
||||
const downloadStub = sinon.stub()
|
||||
wrapper.download = downloadStub
|
||||
wrapper.find('a.download').trigger('click')
|
||||
spy.should.have.been.called
|
||||
downloadStub.should.have.been.called
|
||||
})
|
||||
})
|
||||
|
|
|
@ -45,9 +45,9 @@ describe('components/main-wrapper/main-content/home', () => {
|
|||
|
||||
it('refreshes when a new song is played', () => {
|
||||
const wrapper = shallow(Home)
|
||||
const spy = sinon.spy()
|
||||
wrapper.refreshDashboard = spy
|
||||
const refreshDashboardStub = sinon.stub()
|
||||
wrapper.refreshDashboard = refreshDashboardStub
|
||||
event.emit('song:played')
|
||||
spy.should.have.been.called
|
||||
refreshDashboardStub.should.have.been.called
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue