[IMP] store: return data from committing a mutation

closes #29
This commit is contained in:
Alexandre Kühn
2019-04-15 10:24:08 +02:00
committed by Géry Debongnie
parent 7e7226213a
commit e005090296
2 changed files with 17 additions and 1 deletions
+15
View File
@@ -95,6 +95,21 @@ describe("basic use", () => {
expect(store.state.n).toBe(11);
});
test("return data from committing a mutation", () => {
const state = { n: 1 };
const mutations = {
inc({ state }) {
return ++state.n;
},
};
const store = new Store({ state, mutations });
expect(store.state.n).toBe(1);
const res = store.commit("inc");
expect(store.state.n).toBe(2);
expect(res).toBe(2);
});
test("dispatch allow synchronizing between actions", async () => {
const state = { n: 1 };
const mutations = {