Add tests for extra/artist-info

This commit is contained in:
Phan An 2017-12-11 00:31:27 +01:00
parent 66e1329cc8
commit 77fdc4119f
2 changed files with 58 additions and 0 deletions

View file

@ -0,0 +1,12 @@
export default {
id: 1,
name: 'Awesome Koel Artist',
info: {
image: 'http://foo/bar.jpg',
bio: {
summary: 'This is the summarized biography of Koel Artist',
full: 'This is the full biography of Koel Artist'
},
url: 'http://foo/bar'
}
}

View file

@ -0,0 +1,46 @@
import ArtistInfo from '@/components/main-wrapper/extra/artist-info.vue'
import artist from '@/tests/blobs/artist'
describe('components/main-wrapper/extra/artist-info', () => {
it('displays the info as a sidebar by default', () => {
const wrapper = shallow(ArtistInfo, {
propsData: {
artist
}
})
expect(wrapper.findAll('#artistInfo.sidebar')).toHaveLength(1)
expect(wrapper.findAll('#artistInfo.full')).toHaveLength(0)
})
it('can display the info in full mode', () => {
const wrapper = shallow(ArtistInfo, {
propsData: {
artist,
mode: 'full'
}
})
expect(wrapper.findAll('#artistInfo.sidebar')).toHaveLength(0)
expect(wrapper.findAll('#artistInfo.full')).toHaveLength(1)
})
it('triggers showing full bio', () => {
const wrapper = shallow(ArtistInfo, {
propsData: {
artist
}
})
wrapper.find('.bio button.more').trigger('click')
expect(wrapper.html()).toContain(artist.info.bio.full)
})
it('displays a message if the artist has no info', () => {
const artistWithNoInfo = _.clone(artist)
artistWithNoInfo.info = null
const wrapper = mount(ArtistInfo, {
propsData: {
artist: artistWithNoInfo
}
})
expect(wrapper.html()).toContain('Nothing can be found. This artist is a mystery.')
})
})