mirror of
https://github.com/koel/koel
synced 2024-11-28 06:50:27 +00:00
Add tests for view-mode-switch.vue
This commit is contained in:
parent
26fe41c2bd
commit
af6c92b8bc
4 changed files with 19 additions and 5 deletions
|
@ -2,7 +2,7 @@
|
|||
<section id="albumsWrapper">
|
||||
<h1 class="heading">
|
||||
<span>Albums</span>
|
||||
<view-mode-switch :mode="viewMode" for="albums"/>
|
||||
<view-mode-switch :mode="viewMode" for="albums" @viewModeChanged="changeViewMode"/>
|
||||
</h1>
|
||||
|
||||
<div ref="scroller" class="albums main-scroll-wrap" :class="`as-${viewMode}`" @scroll="scrolling">
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<section id="artistsWrapper">
|
||||
<h1 class="heading">
|
||||
<span>Artists</span>
|
||||
<view-mode-switch :mode="viewMode" for="artists"/>
|
||||
<view-mode-switch :mode="viewMode" for="artists" @viewModeChanged="changeViewMode"/>
|
||||
</h1>
|
||||
|
||||
<div class="artists main-scroll-wrap" :class="`as-${viewMode}`" @scroll="scrolling">
|
||||
|
|
|
@ -20,12 +20,12 @@ export default {
|
|||
mode: {
|
||||
type: String,
|
||||
default: 'thumbnails',
|
||||
validator: value => ['thumbnails', 'list'].indexOf(value) !== -1
|
||||
validator: value => ['thumbnails', 'list'].includes(value)
|
||||
},
|
||||
for: {
|
||||
type: String,
|
||||
required: true,
|
||||
validator: value => ['albums', 'artists'].indexOf(value) !== -1
|
||||
validator: value => ['albums', 'artists'].includes(value)
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -49,7 +49,7 @@ export default {
|
|||
methods: {
|
||||
setMode (mode) {
|
||||
preferences[this.preferenceKey] = this.mutatedMode = mode
|
||||
this.$parent.changeViewMode(mode)
|
||||
this.$emit('viewModeChanged', mode)
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
import Component from '@/components/shared/view-mode-switch.vue'
|
||||
|
||||
describe('components/shared/view-mode-switch', () => {
|
||||
it('changes the view mode', () => {
|
||||
const wrapper = shallow(Component, { propsData: {
|
||||
mode: 'list',
|
||||
for: 'albums'
|
||||
}})
|
||||
wrapper.find('a.thumbnails').trigger('click')
|
||||
wrapper.emitted().viewModeChanged[0].should.eql(['thumbnails'])
|
||||
wrapper.find('a.list').trigger('click')
|
||||
wrapper.emitted().viewModeChanged[1].should.eql(['list'])
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue