update test helpers and improve widget tests

This commit is contained in:
Géry Debongnie
2019-02-06 10:33:12 +01:00
parent 49ecc05297
commit 9b947d8118
7 changed files with 199 additions and 54 deletions
+10 -5
View File
@@ -1,24 +1,27 @@
import { Navbar, Props } from "../../src/ts/widgets/navbar";
import { makeTestEnv, makeTestFixture, loadTemplates } from "../helpers";
import * as helpers from "../helpers";
import { MenuInfo } from "../../src/ts/widgets/root";
//------------------------------------------------------------------------------
// Setup and helpers
//------------------------------------------------------------------------------
let fixture: HTMLElement;
let env: ReturnType<typeof makeTestEnv>;
let env: ReturnType<typeof helpers.makeTestEnv>;
let props: Props;
let menuInfo: MenuInfo;
let templates: string;
beforeAll(async () => {
templates = await loadTemplates();
templates = await helpers.loadTemplates();
});
beforeEach(() => {
fixture = makeTestFixture();
env = makeTestEnv();
fixture = helpers.makeTestFixture();
env = helpers.makeTestEnv();
env.qweb.loadTemplates(templates);
props = { inHome: false, app: null };
menuInfo = helpers.makeDemoMenuInfo();
});
afterEach(() => {
@@ -36,12 +39,14 @@ test("can be rendered", async () => {
});
test("can render one menu item", async () => {
props.app = menuInfo.menus[96]!;
const navbar = new Navbar(env, props);
await navbar.mount(fixture);
expect(fixture.innerHTML).toMatchSnapshot();
});
test("mobile mode: navbar is different", async () => {
props.app = menuInfo.menus[205]!;
env.isMobile = true;
const navbar = new Navbar(env, props);
await navbar.mount(fixture);