mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
imp: add env to store dispatch
This is useful to allow actions to use specific environment methods. For example, one might want to add a rpc method to the environment.
This commit is contained in:
committed by
Géry Debongnie
parent
d10426c720
commit
7027ff1eb6
@@ -41,6 +41,19 @@ describe("basic use", () => {
|
||||
expect(store.state.n).toBe(15);
|
||||
});
|
||||
|
||||
test("env is given to actions", () => {
|
||||
expect.assertions(1);
|
||||
const someEnv = {};
|
||||
const actions = {
|
||||
someaction({ env }) {
|
||||
expect(env).toBe(someEnv);
|
||||
}
|
||||
};
|
||||
const store = new Store({ state: {}, actions, env: someEnv });
|
||||
|
||||
store.dispatch("someaction");
|
||||
});
|
||||
|
||||
test("multiple commits trigger one update", async () => {
|
||||
let updateCounter = 0;
|
||||
const state = { n: 1 };
|
||||
|
||||
Reference in New Issue
Block a user