mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
committed by
Géry Debongnie
parent
7e7226213a
commit
e005090296
+2
-1
@@ -74,7 +74,7 @@ export class Store extends EventBus {
|
||||
this._isMutating = true;
|
||||
this.observer.allowMutations = true;
|
||||
|
||||
this.mutations[type].call(
|
||||
const res = this.mutations[type].call(
|
||||
null,
|
||||
{
|
||||
commit: this.commit.bind(this),
|
||||
@@ -103,6 +103,7 @@ export class Store extends EventBus {
|
||||
});
|
||||
}
|
||||
this._commitLevel--;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user