mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-05 04:49:24 +02:00
Now load instance settings on page load
This commit is contained in:
parent
bb9a614aa7
commit
aa67be9063
4 changed files with 117 additions and 0 deletions
70
front/test/unit/specs/store/instance.spec.js
Normal file
70
front/test/unit/specs/store/instance.spec.js
Normal file
|
@ -0,0 +1,70 @@
|
|||
var sinon = require('sinon')
|
||||
import moxios from 'moxios'
|
||||
import store from '@/store/instance'
|
||||
import { testAction } from '../../utils'
|
||||
|
||||
describe('store/instance', () => {
|
||||
var sandbox
|
||||
|
||||
beforeEach(function () {
|
||||
sandbox = sinon.sandbox.create()
|
||||
moxios.install()
|
||||
})
|
||||
afterEach(function () {
|
||||
sandbox.restore()
|
||||
moxios.uninstall()
|
||||
})
|
||||
|
||||
describe('mutations', () => {
|
||||
it('settings', () => {
|
||||
const state = {settings: {raven: {front_dsn: {value: 'test'}}}}
|
||||
let settings = {raven: {front_enabled: {value: true}}}
|
||||
store.mutations.settings(state, settings)
|
||||
expect(state.settings).to.deep.equal({
|
||||
raven: {front_dsn: {value: 'test'}, front_enabled: {value: true}}
|
||||
})
|
||||
})
|
||||
})
|
||||
describe('actions', () => {
|
||||
it('fetchSettings', (done) => {
|
||||
moxios.stubRequest('instance/settings/', {
|
||||
status: 200,
|
||||
response: [
|
||||
{
|
||||
section: 'raven',
|
||||
name: 'front_dsn',
|
||||
value: 'test'
|
||||
},
|
||||
{
|
||||
section: 'raven',
|
||||
name: 'front_enabled',
|
||||
value: false
|
||||
}
|
||||
]
|
||||
})
|
||||
testAction({
|
||||
action: store.actions.fetchSettings,
|
||||
payload: null,
|
||||
expectedMutations: [
|
||||
{
|
||||
type: 'settings',
|
||||
payload: {
|
||||
raven: {
|
||||
front_dsn: {
|
||||
section: 'raven',
|
||||
name: 'front_dsn',
|
||||
value: 'test'
|
||||
},
|
||||
front_enabled: {
|
||||
section: 'raven',
|
||||
name: 'front_enabled',
|
||||
value: false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}, done)
|
||||
})
|
||||
})
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue