mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
refactoring: widgets -> ui, discuss in subfolder
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
import { Env, makeEnv } from "../../src/ts/env";
|
||||
import { Store } from "../../src/ts/store/store";
|
||||
import { Root } from "../../src/ts/ui/root";
|
||||
import * as helpers from "../helpers";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Setup and helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
let fixture: HTMLElement;
|
||||
let store: Store;
|
||||
let env: Env;
|
||||
let templates: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
templates = await helpers.loadTemplates();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = helpers.makeTestFixture();
|
||||
store = helpers.makeTestStore();
|
||||
env = makeEnv(store, templates);
|
||||
// props = { menuInfo: helpers.makeDemoMenuInfo() };
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.remove();
|
||||
});
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Tests
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
test("can be rendered (in home menu)", async () => {
|
||||
const root = new Root(env, store);
|
||||
await root.mount(fixture);
|
||||
expect(fixture.innerHTML).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test("if url has action_id, will render action and navigate to proper menu_id", async () => {
|
||||
const router = new helpers.MockRouter({ action_id: "131" });
|
||||
store = helpers.makeTestStore({ router });
|
||||
env = makeEnv(store, templates);
|
||||
await helpers.nextTick();
|
||||
|
||||
const root = new Root(env, store);
|
||||
await root.mount(fixture);
|
||||
await helpers.nextTick();
|
||||
expect(env.services.router.getQuery()).toEqual({
|
||||
action_id: "131",
|
||||
menu_id: "96"
|
||||
});
|
||||
expect(fixture.innerHTML).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test("start with no action => clicks on client action => discuss is rendered", async () => {
|
||||
const root = new Root(env, store);
|
||||
await root.mount(fixture);
|
||||
|
||||
expect(env.services.router.getQuery()).toEqual({ home: true });
|
||||
|
||||
// discuss menu item
|
||||
await (<any>document.querySelector('[data-menu="96"]')).click();
|
||||
await helpers.nextTick();
|
||||
expect(fixture.innerHTML).toMatchSnapshot();
|
||||
expect(env.services.router.getQuery()).toEqual({
|
||||
action_id: "131",
|
||||
menu_id: "96"
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user