mirror of
https://github.com/koel/koel
synced 2024-11-24 21:23:06 +00:00
Add tests for YouTube video sidebar
This commit is contained in:
parent
aeefa21752
commit
282fd2cd15
3 changed files with 57 additions and 3 deletions
|
@ -53,9 +53,13 @@ export default {
|
|||
*/
|
||||
async loadMore () {
|
||||
this.loading = true
|
||||
await youtubeService.searchVideosRelatedToSong(this.song)
|
||||
this.videos = this.song.youtube.items
|
||||
this.loading = false
|
||||
try {
|
||||
await youtubeService.searchVideosRelatedToSong(this.song)
|
||||
this.videos = this.song.youtube.items
|
||||
this.loading = false
|
||||
} catch (e) {
|
||||
this.loading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
26
resources/assets/js/tests/blobs/youtube-videos.js
Normal file
26
resources/assets/js/tests/blobs/youtube-videos.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
export default [
|
||||
{
|
||||
id: { videoId: 'foo' },
|
||||
snippet: {
|
||||
title: 'Koel YouTube video #1',
|
||||
description: 'Description for Koel YouTube video #1',
|
||||
thumbnails: {
|
||||
default: {
|
||||
url: 'http://youtube/thumb-1.png'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
id: { videoId: 'bar' },
|
||||
snippet: {
|
||||
title: 'Koel YouTube video #2',
|
||||
description: 'Description for Koel YouTube video #2',
|
||||
thumbnails: {
|
||||
default: {
|
||||
url: 'http://youtube/thumb-2.png'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
|
@ -0,0 +1,24 @@
|
|||
import YouTube from '@/components/main-wrapper/extra/youtube.vue'
|
||||
import song from '@/tests/blobs/song'
|
||||
import videos from '@/tests/blobs/youtube-videos'
|
||||
|
||||
describe('components/main-wrapper/extra/youtube', () => {
|
||||
let wrapper
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(YouTube, {
|
||||
propsData: { song }
|
||||
})
|
||||
wrapper.setData({ videos })
|
||||
})
|
||||
|
||||
it('displays a list of videos', () => {
|
||||
wrapper.findAll('a.video').should.have.lengthOf(2)
|
||||
})
|
||||
|
||||
it('loads more videos on demand', () => {
|
||||
const spy = sinon.spy()
|
||||
wrapper.vm.loadMore = spy
|
||||
wrapper.find('button.more').trigger('click')
|
||||
spy.should.have.been.called
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue