mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
@@ -2142,7 +2142,7 @@ describe("other directives with t-component", () => {
|
||||
<Child t-on-ev="handler"/>
|
||||
</div>`;
|
||||
static components = { Child };
|
||||
state = useState({counter: 0});
|
||||
state = useState({ counter: 0 });
|
||||
get handler() {
|
||||
this.state.counter++;
|
||||
return () => {};
|
||||
@@ -2152,12 +2152,12 @@ describe("other directives with t-component", () => {
|
||||
await parent.mount(fixture);
|
||||
|
||||
expect(env.qweb.templates[Parent.template].fn.toString()).toMatchSnapshot();
|
||||
expect(fixture.innerHTML).toBe('<div>0<span></span></div>');
|
||||
expect(fixture.innerHTML).toBe("<div>0<span></span></div>");
|
||||
|
||||
let child = children(parent)[0];
|
||||
child.trigger("ev");
|
||||
await nextTick();
|
||||
expect(fixture.innerHTML).toBe('<div>1<span></span></div>');
|
||||
expect(fixture.innerHTML).toBe("<div>1<span></span></div>");
|
||||
});
|
||||
|
||||
test("t-on with inline statement", async () => {
|
||||
@@ -2171,18 +2171,18 @@ describe("other directives with t-component", () => {
|
||||
<Child t-on-ev="state.counter++"/>
|
||||
</div>`;
|
||||
static components = { Child };
|
||||
state = useState({counter: 0});
|
||||
state = useState({ counter: 0 });
|
||||
}
|
||||
const parent = new Parent(env);
|
||||
await parent.mount(fixture);
|
||||
|
||||
expect(env.qweb.templates[Parent.template].fn.toString()).toMatchSnapshot();
|
||||
expect(fixture.innerHTML).toBe('<div>0<span></span></div>');
|
||||
expect(fixture.innerHTML).toBe("<div>0<span></span></div>");
|
||||
|
||||
let child = children(parent)[0];
|
||||
child.trigger("ev");
|
||||
await nextTick();
|
||||
expect(fixture.innerHTML).toBe('<div>1<span></span></div>');
|
||||
expect(fixture.innerHTML).toBe("<div>1<span></span></div>");
|
||||
});
|
||||
|
||||
test("t-on with no handler (only modifiers)", async () => {
|
||||
|
||||
@@ -1044,8 +1044,8 @@ describe("t-on", () => {
|
||||
qweb.addTemplate("test", `<button t-on-click="state.counter++">Click</button>`);
|
||||
let owner = {
|
||||
state: {
|
||||
counter: 0,
|
||||
},
|
||||
counter: 0
|
||||
}
|
||||
};
|
||||
const node = renderToDOM(qweb, "test", owner, { handlers: [] });
|
||||
expect(owner.state.counter).toBe(0);
|
||||
@@ -1058,8 +1058,10 @@ describe("t-on", () => {
|
||||
let owner = {
|
||||
state: {
|
||||
counter: 0,
|
||||
incrementCounter: (inc) => { owner.state.counter += inc; },
|
||||
},
|
||||
incrementCounter: inc => {
|
||||
owner.state.counter += inc;
|
||||
}
|
||||
}
|
||||
};
|
||||
const node = renderToDOM(qweb, "test", owner, { handlers: [] });
|
||||
expect(owner.state.counter).toBe(0);
|
||||
@@ -1223,7 +1225,7 @@ describe("t-on", () => {
|
||||
);
|
||||
const node = renderToDOM(qweb, "test", {}, { handlers: [] });
|
||||
|
||||
node.addEventListener('click', (e) => {
|
||||
node.addEventListener("click", e => {
|
||||
expect(e.defaultPrevented).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user