mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
move internal stuff in _, add unique id for each widget
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { escape, htmlTrim } from "../src/ts/core/utils";
|
||||
import { escape, htmlTrim, idGenerator } from "../src/ts/core/utils";
|
||||
|
||||
describe("escape", () => {
|
||||
test("normal strings", () => {
|
||||
@@ -25,3 +25,12 @@ describe("htmlTrim", () => {
|
||||
expect(htmlTrim("")).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
describe("idGenerator", () => {
|
||||
test("basic use", () => {
|
||||
let gen = idGenerator();
|
||||
expect(gen()).toBe(1);
|
||||
expect(gen()).toBe(2);
|
||||
expect(gen()).toBe(3);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Widget, WEnv } from "../src/ts/core/widget";
|
||||
import { idGenerator } from "../src/ts/core/utils";
|
||||
import { QWeb } from "../src/ts/core/qweb_vdom";
|
||||
|
||||
interface Type<T> extends Function {
|
||||
@@ -9,8 +10,9 @@ type TestEnv = WEnv;
|
||||
type TestWidget = Widget<TestEnv>;
|
||||
|
||||
function makeWidget(W: Type<TestWidget>): TestWidget {
|
||||
const env = {
|
||||
qweb: new QWeb()
|
||||
const env: WEnv = {
|
||||
qweb: new QWeb(),
|
||||
getID: idGenerator()
|
||||
};
|
||||
const w = new W(env);
|
||||
return w;
|
||||
|
||||
Reference in New Issue
Block a user