Quellcode durchsuchen

add SET_VERSION mutation

pull/342/head
Guillaume Vincent vor 7 Jahren
Ursprung
Commit
90abe71e14
3 geänderte Dateien mit 27 neuen und 1 gelöschten Zeilen
  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 Datei anzeigen

@@ -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 Datei anzeigen

@@ -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 Datei anzeigen

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

Laden…
Abbrechen
Speichern