fix issue with actioncontainer, add tests

This commit is contained in:
Géry Debongnie
2019-02-06 13:26:21 +01:00
parent 7aa252c222
commit 91e51b2798
9 changed files with 198 additions and 34 deletions
+17 -4
View File
@@ -30,16 +30,29 @@ afterEach(() => {
//------------------------------------------------------------------------------
test("can be rendered (in home menu)", async () => {
const navbar = new Root(env, props);
await navbar.mount(fixture);
const root = new Root(env, props);
await root.mount(fixture);
expect(fixture.innerHTML).toMatchSnapshot();
});
test("if url has action_id, will render action and navigate to proper menu_id", async () => {
env.router.setQuery({ action_id: "595" });
const navbar = new Root(env, props);
await navbar.mount(fixture);
const root = new Root(env, props);
await root.mount(fixture);
expect(fixture.innerHTML).toMatchSnapshot();
// we check here that the url was changed to set app id as menu_id
expect(env.router.currentQuery).toEqual({ action_id: "595", menu_id: "409" });
});
test("start with no action => clicks on client action => discuss is rendered", async () => {
const root = new Root(env, props);
await root.mount(fixture);
expect(env.router.currentQuery).toEqual({});
// discuss menu item
await (<any>document.querySelector('[data-menu="96"]')).click();
await helpers.nextTick();
expect(fixture.innerHTML).toMatchSnapshot();
expect(env.router.currentQuery).toEqual({ action_id: "131", menu_id: "96" });
});