add test helpers, add navbar tests

This commit is contained in:
Géry Debongnie
2019-01-29 10:46:01 +01:00
parent b024ce3183
commit dd75a17448
5 changed files with 126 additions and 10 deletions
+50
View File
@@ -0,0 +1,50 @@
import { Env } from "../../src/ts/env";
import { makeTestEnv, makeTestFixture, normalize } from "../helpers";
import { Navbar } from "../../src/ts/widgets/navbar";
//------------------------------------------------------------------------------
// Setup and helpers
//------------------------------------------------------------------------------
let fixture: HTMLElement;
let env: Env;
beforeEach(() => {
fixture = makeTestFixture();
env = makeTestEnv();
});
afterEach(() => {
fixture.remove();
});
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
test("can be rendered", async () => {
const navbar = new Navbar(env);
await navbar.mount(fixture);
expect(normalize(fixture.innerHTML)).toBe(
normalize(`
<div class=\"o_navbar\">
<span class=\"title\">Odoo</span>
<ul></ul>
</div>`)
);
});
test("can render one menu item", async () => {
env.menus.push({ title: "menu", actionID: 4 });
const navbar = new Navbar(env);
await navbar.mount(fixture);
expect(normalize(fixture.innerHTML)).toBe(
normalize(`
<div class=\"o_navbar\">
<span class=\"title\">Odoo</span>
<ul>
<li><ahref=\"\">menu</a></li>
</ul>
</div>`)
);
});