work on home menu

This commit is contained in:
Géry Debongnie
2019-02-03 15:05:53 +01:00
parent b244ba7304
commit b292a66523
9 changed files with 228 additions and 93 deletions
@@ -0,0 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`can be rendered 1`] = `
"<div class=\\"o_home_menu\\">
<div class=\\"o_apps\\">
<a href=\\"#\\" class=\\"o_app\\">
<i class=\\"fa fa-test o_app_icon fa-3x fa-fw\\"></i>
<div class=\\"o_caption\\">
Demo
</div>
</a>
</div>
</div>"
`;
@@ -2,34 +2,34 @@
exports[`can be rendered 1`] = `
"<div class=\\"o_navbar\\">
<a aria-label=\\"Applications\\" class=\\"o_title fa fa-th\\" href=\\"#\\" title=\\"Applications\\" accesskey=\\"h\\"></a>
<ul>
</ul>
</div>"
<a aria-label=\\"Applications\\" class=\\"o_title fa fa-th\\" href=\\"#\\" title=\\"Applications\\" accesskey=\\"h\\"></a>
<ul>
</ul>
</div>"
`;
exports[`can render one menu item 1`] = `
"<div class=\\"o_navbar\\">
<a aria-label=\\"Applications\\" class=\\"o_title fa fa-th\\" href=\\"#\\" title=\\"Applications\\" accesskey=\\"h\\"></a>
<ul>
<li>
<a href=\\"\\">
menu
</a>
</li>
</ul>
</div>"
<a aria-label=\\"Applications\\" class=\\"o_title fa fa-th\\" href=\\"#\\" title=\\"Applications\\" accesskey=\\"h\\"></a>
<ul>
<li>
<a href=\\"\\">
menu
</a>
</li>
</ul>
</div>"
`;
exports[`mobile mode: navbar is different 1`] = `
"<div class=\\"o_navbar\\">
<a aria-label=\\"Applications\\" class=\\"o_title fa fa-th\\" href=\\"#\\" title=\\"Applications\\" accesskey=\\"h\\"></a>
<ul>
<li>MOBILEMODE</li>
</ul>
</div>"
<a aria-label=\\"Applications\\" class=\\"o_title fa fa-th\\" href=\\"#\\" title=\\"Applications\\" accesskey=\\"h\\"></a>
<ul>
<li>MOBILEMODE</li>
</ul>
</div>"
`;
@@ -2,9 +2,8 @@
exports[`can be rendered 1`] = `
"<div class=\\"o_notification\\">
<div class=\\"o_notification_title\\">title</div>
<div class=\\"o_notification_content\\">message</div>
</div>"
<div class=\\"o_notification_title\\">title</div>
<div class=\\"o_notification_content\\">message</div>
</div>"
`;
@@ -0,0 +1,51 @@
import { Env } from "../../src/ts/env";
import { HomeMenu, Props } from "../../src/ts/widgets/home_menu";
import { makeTestEnv, makeTestFixture, loadTemplates } from "../helpers";
//------------------------------------------------------------------------------
// Setup and helpers
//------------------------------------------------------------------------------
let fixture: HTMLElement;
let env: Env;
let props: Props;
let templates: string;
beforeAll(async () => {
templates = await loadTemplates();
});
beforeEach(() => {
fixture = makeTestFixture();
env = makeTestEnv();
env.qweb.loadTemplates(templates);
props = {
menuInfo: {
menuMap: {
14: {
id: 14,
name: "Demo",
parent_id: false,
action: false,
icon: "fa fa-test",
children: []
}
},
roots: [14]
}
};
});
afterEach(() => {
fixture.remove();
});
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
test("can be rendered", async () => {
const homeMenu = new HomeMenu(env, props);
await homeMenu.mount(fixture);
expect(fixture.innerHTML).toMatchSnapshot();
});
+1 -1
View File
@@ -19,7 +19,7 @@ beforeEach(() => {
fixture = makeTestFixture();
env = makeTestEnv();
env.qweb.loadTemplates(templates);
props = { inMenu: false, toggleHome: () => {} };
props = { inHome: false };
});
afterEach(() => {