add basic support for mobile mode

This commit is contained in:
Géry Debongnie
2019-01-30 12:34:45 +01:00
parent 6012d76388
commit c627f87463
7 changed files with 78 additions and 3 deletions
+19 -1
View File
@@ -2,7 +2,8 @@ import {
escape,
htmlTrim,
idGenerator,
memoize
memoize,
debounce
} from "../../src/ts/core/utils";
describe("escape", () => {
@@ -59,3 +60,20 @@ describe("memoize", () => {
expect(nCalls).toBe(1);
});
});
describe("debounce", () => {
test("works as expected", () => {
jest.useFakeTimers();
let n = 0;
let f = debounce(() => n++, 100);
expect(n).toBe(0);
f();
expect(n).toBe(0);
f();
expect(n).toBe(0);
jest.advanceTimersByTime(90);
expect(n).toBe(0);
jest.advanceTimersByTime(20);
expect(n).toBe(1);
});
});
@@ -21,3 +21,12 @@ exports[`can render one menu item 1`] = `
</ul>
</div>"
`;
exports[`mobile mode: navbar is different 1`] = `
"<div class=\\"o_navbar\\">
<span class=\\"title\\">Odoo MOBILE</span>
<ul>
</ul>
</div>"
`;
+7
View File
@@ -34,3 +34,10 @@ test("can render one menu item", async () => {
await navbar.mount(fixture);
expect(fixture.innerHTML).toMatchSnapshot();
});
test("mobile mode: navbar is different", async () => {
env.isMobile = true;
const navbar = new Navbar(env);
await navbar.mount(fixture);
expect(fixture.innerHTML).toMatchSnapshot();
});