Files
owl/tests/utils.test.ts
T

31 lines
648 B
TypeScript
Raw Normal View History

2019-05-17 23:26:42 +02:00
import { escape, debounce } from "../src/utils";
2019-01-16 11:28:05 +01:00
describe("escape", () => {
test("normal strings", () => {
const text = "abc";
expect(escape(text)).toBe(text);
});
test("special symbols", () => {
const text = "<ok>";
expect(escape(text)).toBe("&lt;ok&gt;");
});
});
2019-01-30 12:34:45 +01:00
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);
});
});