@@ -4,4 +4,5 @@ export const SET_CURRENT_PASSWORD = 'SET_CURRENT_PASSWORD'; | |||||
export const SET_DEFAULT_PASSWORD = 'SET_DEFAULT_PASSWORD'; | export const SET_DEFAULT_PASSWORD = 'SET_DEFAULT_PASSWORD'; | ||||
export const SET_PASSWORDS = 'SET_PASSWORDS'; | export const SET_PASSWORDS = 'SET_PASSWORDS'; | ||||
export const DELETE_PASSWORD = 'DELETE_PASSWORD'; | export const DELETE_PASSWORD = 'DELETE_PASSWORD'; | ||||
export const SET_BASE_URL = 'SET_BASE_URL'; | |||||
export const SET_BASE_URL = 'SET_BASE_URL'; | |||||
export const SET_VERSION = 'SET_VERSION'; |
@@ -32,5 +32,12 @@ export const mutations = { | |||||
}, | }, | ||||
[types.SET_BASE_URL](state, {baseURL}){ | [types.SET_BASE_URL](state, {baseURL}){ | ||||
state.baseURL = baseURL; | state.baseURL = baseURL; | ||||
}, | |||||
[types.SET_VERSION](state, {version}){ | |||||
if (state.currentPassword === null) { | |||||
state.currentPassword = {version}; | |||||
} else { | |||||
state.currentPassword.version = version; | |||||
} | |||||
} | } | ||||
}; | }; |
@@ -166,4 +166,22 @@ test('SET_BASE_URL', t => { | |||||
const baseURL = 'https://example.org'; | const baseURL = 'https://example.org'; | ||||
SET_BASE_URL(state, {baseURL: baseURL}); | SET_BASE_URL(state, {baseURL: baseURL}); | ||||
t.is(state.baseURL, baseURL); | t.is(state.baseURL, baseURL); | ||||
}); | |||||
test('SET_VERSION', t => { | |||||
const SET_VERSION = mutations[types.SET_VERSION]; | |||||
const state = { | |||||
currentPassword: {version: 2}, | |||||
}; | |||||
SET_VERSION(state, {version: 1}); | |||||
t.is(state.currentPassword.version, 1); | |||||
}); | |||||
test('SET_VERSION currentPassword null', t => { | |||||
const SET_VERSION = mutations[types.SET_VERSION]; | |||||
const state = { | |||||
currentPassword: null, | |||||
}; | |||||
SET_VERSION(state, {version: 2}); | |||||
t.is(state.currentPassword.version, 2); | |||||
}); | }); |