mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] store: commit a mutation in a mutation
This commit is contained in:
committed by
Géry Debongnie
parent
9ee85e220b
commit
7e7226213a
@@ -76,6 +76,25 @@ describe("basic use", () => {
|
||||
expect(store.state.n).toBe(101);
|
||||
});
|
||||
|
||||
test("can commit a mutation in a mutation", () => {
|
||||
const state = { n: 1 };
|
||||
const mutations = {
|
||||
inc({ state }) {
|
||||
state.n++;
|
||||
},
|
||||
inc10({ commit }) {
|
||||
for (let i = 0; i < 10; i++) {
|
||||
commit("inc");
|
||||
}
|
||||
}
|
||||
};
|
||||
const store = new Store({ state, mutations });
|
||||
|
||||
expect(store.state.n).toBe(1);
|
||||
store.commit("inc10");
|
||||
expect(store.state.n).toBe(11);
|
||||
});
|
||||
|
||||
test("dispatch allow synchronizing between actions", async () => {
|
||||
const state = { n: 1 };
|
||||
const mutations = {
|
||||
|
||||
Reference in New Issue
Block a user