@@ -1,3 +0,0 @@ | |||||
export const LOGIN = 'LOGIN'; | |||||
export const LOGOUT = 'LOGOUT'; | |||||
export const SET_CURRENT_PASSWORD_PROFILE = 'SET_CURRENT_PASSWORD_PROFILE'; |
@@ -1,13 +1,20 @@ | |||||
import * as types from './mutation-types'; | |||||
import {set} from 'vue'; | |||||
function setState(state, id, object) { | |||||
set(state, id, Object.assign({}, object)); | |||||
} | |||||
export const mutations = { | export const mutations = { | ||||
[types.LOGIN](state){ | |||||
LOGIN(state){ | |||||
state.authenticated = true; | state.authenticated = true; | ||||
}, | }, | ||||
[types.LOGOUT](state){ | |||||
LOGOUT(state){ | |||||
state.authenticated = false; | state.authenticated = false; | ||||
}, | }, | ||||
[types.SET_CURRENT_PASSWORD_PROFILE](state, passwordProfile){ | |||||
state.currentPasswordProfile = passwordProfile; | |||||
SET_CURRENT_PASSWORD_PROFILE(state, passwordProfile){ | |||||
setState(state, 'currentPasswordProfile', passwordProfile); | |||||
}, | |||||
SET_DEFAULT_OPTIONS(state, options){ | |||||
setState(state, 'defaultOptions', options); | |||||
} | } | ||||
}; | }; |
@@ -22,6 +22,36 @@ test('SET_CURRENT_PASSWORD_PROFILE', t => { | |||||
uppercase: true, | uppercase: true, | ||||
version: 2 | version: 2 | ||||
}); | }); | ||||
t.true(state.currentPasswordProfile.version == 2); | |||||
t.is(state.currentPasswordProfile.version, 2); | |||||
t.true(state.currentPasswordProfile.uppercase); | t.true(state.currentPasswordProfile.uppercase); | ||||
}); | |||||
test('SET_CURRENT_PASSWORD_PROFILE immutable', t => { | |||||
const {SET_CURRENT_PASSWORD_PROFILE} = mutations; | |||||
const state = {}; | |||||
const profile = {version: 2}; | |||||
SET_CURRENT_PASSWORD_PROFILE(state, profile); | |||||
profile.version = 1; | |||||
t.is(state.currentPasswordProfile.version, 2); | |||||
}); | |||||
test('SET_DEFAULT_OPTIONS', t => { | |||||
const {SET_DEFAULT_OPTIONS} = mutations; | |||||
const state = { | |||||
defaultOptions: { | |||||
uppercase: true, | |||||
lowercase: true, | |||||
numbers: true, | |||||
symbols: true, | |||||
length: 16, | |||||
counter: 1, | |||||
version: 2 | |||||
} | |||||
}; | |||||
SET_DEFAULT_OPTIONS(state, { | |||||
symbols: false, | |||||
length: 30 | |||||
}); | |||||
t.is(state.defaultOptions.length, 30); | |||||
t.false(state.defaultOptions.symbols); | |||||
}); | }); |