use snapshot testing

This commit is contained in:
Géry Debongnie
2019-01-30 10:22:24 +01:00
parent bc6bf5354f
commit be7ff1faf0
5 changed files with 40 additions and 27 deletions
+3 -17
View File
@@ -1,6 +1,6 @@
import { Env } from "../../src/ts/env";
import { makeTestEnv, makeTestFixture, normalize } from "../helpers";
import { Navbar } from "../../src/ts/widgets/navbar";
import { makeTestEnv, makeTestFixture } from "../helpers";
//------------------------------------------------------------------------------
// Setup and helpers
@@ -25,26 +25,12 @@ afterEach(() => {
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>`)
);
expect(fixture.innerHTML).toMatchSnapshot();
});
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>`)
);
expect(fixture.innerHTML).toMatchSnapshot();
});