Explorar el Código

add SET_VERSION mutation

pull/342/head
Guillaume Vincent hace 7 años
padre
commit
90abe71e14
Se han modificado 3 ficheros con 27 adiciones y 1 borrados
  1. +2
    -1
      src/store/mutation-types.js
  2. +7
    -0
      src/store/mutations.js
  3. +18
    -0
      test/store.js

+ 2
- 1
src/store/mutation-types.js Ver fichero

@@ -4,4 +4,5 @@ export const SET_CURRENT_PASSWORD = 'SET_CURRENT_PASSWORD';
export const SET_DEFAULT_PASSWORD = 'SET_DEFAULT_PASSWORD';
export const SET_PASSWORDS = 'SET_PASSWORDS';
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';

+ 7
- 0
src/store/mutations.js Ver fichero

@@ -32,5 +32,12 @@ export const mutations = {
},
[types.SET_BASE_URL](state, {baseURL}){
state.baseURL = baseURL;
},
[types.SET_VERSION](state, {version}){
if (state.currentPassword === null) {
state.currentPassword = {version};
} else {
state.currentPassword.version = version;
}
}
};

+ 18
- 0
test/store.js Ver fichero

@@ -166,4 +166,22 @@ test('SET_BASE_URL', t => {
const baseURL = 'https://example.org';
SET_BASE_URL(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);
});

Cargando…
Cancelar
Guardar