mirror of
https://github.com/koel/koel
synced 2024-11-10 14:44:13 +00:00
Add tests for settings.vue
This commit is contained in:
parent
648fc9f232
commit
fac40bc501
4 changed files with 43 additions and 0 deletions
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,39 @@
|
|||
import Component from '@/components/main-wrapper/main-content/settings.vue'
|
||||
import { sharedStore, settingStore } from '@/stores'
|
||||
import { alerts } from '@/utils'
|
||||
|
||||
describe('components/main-wrapper/main-content/settings', () => {
|
||||
beforeEach(() => {
|
||||
settingStore.state = {
|
||||
settings: {
|
||||
media_path: '/foo/'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
it('renders a settings form', () => {
|
||||
const wrapper = shallow(Component)
|
||||
wrapper.findAll('form').should.have.lengthOf(1)
|
||||
})
|
||||
|
||||
it('warns if changing a non-empty media path', () => {
|
||||
sharedStore.state.originalMediaPath = '/bar'
|
||||
const wrapper = shallow(Component)
|
||||
const stub = sinon.stub(alerts, 'confirm')
|
||||
wrapper.find('form').trigger('submit')
|
||||
stub.called.should.be.true
|
||||
stub.restore()
|
||||
})
|
||||
|
||||
it("doesn't warn if changing an empty media path", () => {
|
||||
sharedStore.state.originalMediaPath = ''
|
||||
const wrapper = shallow(Component)
|
||||
const confirmStub = sinon.stub(alerts, 'confirm')
|
||||
const updateStub = sinon.stub(settingStore, 'update')
|
||||
wrapper.find('form').trigger('submit')
|
||||
confirmStub.called.should.be.false
|
||||
updateStub.called.should.be.true
|
||||
confirmStub.restore()
|
||||
updateStub.restore()
|
||||
})
|
||||
})
|
|
@ -19,6 +19,10 @@ export function loadMainView (view, ...args) {
|
|||
* This is handy for certain cases, for example Last.fm connect/disconnect.
|
||||
*/
|
||||
export function forceReloadWindow () {
|
||||
if (window.__UNIT_TESTING__) {
|
||||
return
|
||||
}
|
||||
|
||||
window.onbeforeunload = function () {}
|
||||
window.location.reload()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue