mirror of
https://github.com/koel/koel
synced 2024-11-10 14:44:13 +00:00
Add tests for profile.vue
This commit is contained in:
parent
eabfef0044
commit
1f6bd29cf9
1 changed files with 50 additions and 0 deletions
|
@ -0,0 +1,50 @@
|
|||
import Profile from '@/components/main-wrapper/main-content/profile.vue'
|
||||
import factory from '@/tests/factory'
|
||||
import { userStore, preferenceStore } from '@/stores'
|
||||
|
||||
describe('components/main-wrapper/main-content/user', () => {
|
||||
beforeEach(() => {
|
||||
userStore.state.current = factory('user')
|
||||
})
|
||||
|
||||
it('displays a form to update profile', () => {
|
||||
const wrapper = shallow(Profile)
|
||||
wrapper.contains('form').should.be.true
|
||||
})
|
||||
|
||||
it('validates password confirmation', () => {
|
||||
const wrapper = shallow(Profile)
|
||||
wrapper.setData({
|
||||
pwd: 'foo',
|
||||
confirmPwd: 'bar'
|
||||
})
|
||||
const updateProfileStub = sinon.stub(userStore, 'updateProfile')
|
||||
wrapper.find('form').trigger('submit')
|
||||
updateProfileStub.called.should.be.false
|
||||
wrapper.setData({
|
||||
confirmPwd: 'foo'
|
||||
})
|
||||
wrapper.find('form').trigger('submit')
|
||||
updateProfileStub.called.should.be.true
|
||||
updateProfileStub.restore()
|
||||
})
|
||||
|
||||
it('updates profile with password fields left empty', () => {
|
||||
const wrapper = shallow(Profile)
|
||||
const updateProfileStub = sinon.stub(userStore, 'updateProfile')
|
||||
wrapper.find('form').trigger('submit')
|
||||
updateProfileStub.called.should.be.true
|
||||
updateProfileStub.restore()
|
||||
})
|
||||
|
||||
it('updates preferences', () => {
|
||||
const wrapper = shallow(Profile)
|
||||
const savePrefsStub = sinon.spy(preferenceStore, 'save')
|
||||
wrapper.setData({ prefs: preferenceStore.state })
|
||||
;['notify', 'confirmClosing', 'transcodeOnMobile'].forEach(key => {
|
||||
wrapper.find(`input[name=${key}]`).trigger('click')
|
||||
savePrefsStub.called.should.be.true
|
||||
})
|
||||
savePrefsStub.restore( )
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue