[FIX] router: update app if parameterized route changes

This commit is contained in:
Géry Debongnie
2019-08-31 15:03:17 +02:00
parent 55be6437f1
commit 40d8090232
7 changed files with 35 additions and 17 deletions
+12
View File
@@ -25,6 +25,18 @@ describe("router miscellaneous", () => {
]);
}).toThrow(`Invalid destination: {"abc":"hey"}`);
});
test("navigate to same route but with different params should trigger update", async () => {
router = new TestRouter(env, [{ name: "users", path: "/users/{{id}}" }]);
env.qweb.forceUpdate = jest.fn();
await router.navigate({ to: "users", params: { id: 3 } });
expect(window.location.pathname).toBe("/users/3");
expect(env.qweb.forceUpdate).toHaveBeenCalledTimes(1);
await router.navigate({ to: "users", params: { id: 5 } });
expect(window.location.pathname).toBe("/users/5");
expect(env.qweb.forceUpdate).toHaveBeenCalledTimes(2);
});
});
describe("routeToPath", () => {