Sfoglia il codice sorgente

add SET_VERSION mutation

pull/342/head
Guillaume Vincent 7 anni fa
parent
commit
90abe71e14
3 ha cambiato i file con 27 aggiunte e 1 eliminazioni
  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 Vedi File

@@ -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 Vedi File

@@ -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 Vedi File

@@ -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);
});

Caricamento…
Annulla
Salva