mirror of
https://github.com/koel/koel
synced 2024-11-28 15:00:42 +00:00
Add tests for album
This commit is contained in:
parent
ce66f06a26
commit
e54aa480fb
3 changed files with 68 additions and 4 deletions
|
@ -132,9 +132,12 @@ export default {
|
|||
async showInfo () {
|
||||
this.info.showing = true
|
||||
if (!this.album.info) {
|
||||
this.info.loading = true
|
||||
await albumInfoService.fetch(this.album)
|
||||
this.info.loading = false
|
||||
try {
|
||||
await albumInfoService.fetch(this.album)
|
||||
} catch (e) {
|
||||
} finally {
|
||||
this.info.loading = false
|
||||
}
|
||||
} else {
|
||||
this.info.loading = false
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
export default {
|
||||
id: 1,
|
||||
name: 'Koel Vol. 1',
|
||||
cover: 'http://foo/cover.jpg',
|
||||
info: {
|
||||
image: 'http://foo/bar.jpg',
|
||||
wiki: {
|
||||
|
@ -12,5 +13,21 @@ export default {
|
|||
{ title: 'Second song', fmtLength: '2:37' },
|
||||
],
|
||||
url: 'http://foo/bar'
|
||||
}
|
||||
},
|
||||
artist: {
|
||||
id: 1,
|
||||
name: 'Koel Artist'
|
||||
},
|
||||
songs: [
|
||||
{
|
||||
id: 'd501d98756733e2f6d875c5de8be40eb',
|
||||
title: 'Song #1',
|
||||
length: 10,
|
||||
},
|
||||
{
|
||||
id: '6d644013c2414ab07d21776ed5876ba4',
|
||||
title: 'Song #2',
|
||||
length: 20
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
import Album from '@/components/main-wrapper/main-content/album.vue'
|
||||
import SongList from '@/components/shared/song-list.vue'
|
||||
import SongListControls from '@/components/shared/song-list-controls.vue'
|
||||
import { event } from '@/utils'
|
||||
import album from '@/tests/blobs/album'
|
||||
import Vue from 'vue'
|
||||
|
||||
describe('components/main-wrapper/main-content/album', () => {
|
||||
it('renders upon receiving event', () => {
|
||||
const wrapper = shallow(Album)
|
||||
event.emit('main-content-view:load', 'album', album)
|
||||
Vue.nextTick(() => {
|
||||
const html = wrapper.html()
|
||||
html.should.contain(album.name)
|
||||
html.should.contain(album.artist.name)
|
||||
wrapper.contains(SongList).should.be.true
|
||||
wrapper.contains(SongListControls).should.be.true
|
||||
})
|
||||
})
|
||||
|
||||
it('loads info from Last.fm', () => {
|
||||
const wrapper = shallow(Album)
|
||||
wrapper.setData({
|
||||
album,
|
||||
sharedState: { useLastfm: true }
|
||||
})
|
||||
const spy = sinon.spy()
|
||||
wrapper.showInfo = spy
|
||||
wrapper.find('a.info').trigger('click')
|
||||
spy.should.have.been.called
|
||||
})
|
||||
|
||||
it('allows downloading', () => {
|
||||
const wrapper = shallow(Album)
|
||||
wrapper.setData({
|
||||
album,
|
||||
sharedState: { allowDownload: true }
|
||||
})
|
||||
const spy = sinon.spy()
|
||||
wrapper.download = spy
|
||||
wrapper.find('a.download').trigger('click')
|
||||
spy.should.have.been.called
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue