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);
});
});