mirror of
https://github.com/koel/koel
synced 2025-02-26 12:17:12 +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">
|
<section id="albumsWrapper">
|
||||||
<h1 class="heading">
|
<h1 class="heading">
|
||||||
<span>Albums</span>
|
<span>Albums</span>
|
||||||
<view-mode-switch :mode="viewMode" for="albums"/>
|
<view-mode-switch :mode="viewMode" for="albums" @viewModeChanged="changeViewMode"/>
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<div ref="scroller" class="albums main-scroll-wrap" :class="`as-${viewMode}`" @scroll="scrolling">
|
<div ref="scroller" class="albums main-scroll-wrap" :class="`as-${viewMode}`" @scroll="scrolling">
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<section id="artistsWrapper">
|
<section id="artistsWrapper">
|
||||||
<h1 class="heading">
|
<h1 class="heading">
|
||||||
<span>Artists</span>
|
<span>Artists</span>
|
||||||
<view-mode-switch :mode="viewMode" for="artists"/>
|
<view-mode-switch :mode="viewMode" for="artists" @viewModeChanged="changeViewMode"/>
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<div class="artists main-scroll-wrap" :class="`as-${viewMode}`" @scroll="scrolling">
|
<div class="artists main-scroll-wrap" :class="`as-${viewMode}`" @scroll="scrolling">
|
||||||
|
|
|
@ -20,12 +20,12 @@ export default {
|
||||||
mode: {
|
mode: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'thumbnails',
|
default: 'thumbnails',
|
||||||
validator: value => ['thumbnails', 'list'].indexOf(value) !== -1
|
validator: value => ['thumbnails', 'list'].includes(value)
|
||||||
},
|
},
|
||||||
for: {
|
for: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
validator: value => ['albums', 'artists'].indexOf(value) !== -1
|
validator: value => ['albums', 'artists'].includes(value)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
setMode (mode) {
|
setMode (mode) {
|
||||||
preferences[this.preferenceKey] = this.mutatedMode = 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…
Add table
Reference in a new issue