Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(): tpl proxied methods should return #4394

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/runtime/src/CustomTemplates.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ describe("customTemplates", () => {
runtimeContext,
};
(refA.element as any).propA = "a2";
const methodM = ((refA.element as any).methodM = jest.fn());
const methodM = ((refA.element as any).methodM = jest.fn(() => "M"));
const refB: RuntimeBrick = {
type: "div",
element: document.createElement("div"),
runtimeContext,
};
(refB.element as any).propC = "b2";
const methodL = ((refB.element as any).methodL = jest.fn());
const methodL = ((refB.element as any).methodL = jest.fn(() => "L"));
const hostBrick: RuntimeBrick = {
type: "tpl-proxy",
tplHostMetadata: {
Expand Down Expand Up @@ -172,10 +172,12 @@ describe("customTemplates", () => {
expect(tpl.propA).toBe("a2");
expect(tpl.propB).toBe("b2");

(tpl as any).methodM("p");
const resultM = (tpl as any).methodM("p");
expect(resultM).toBe("M");
expect(methodM).toBeCalledTimes(1);
expect(methodM).toHaveBeenNthCalledWith(1, "p");
(tpl as any).methodN("q");
const resultN = (tpl as any).methodN("q");
expect(resultN).toBe("L");
expect(methodL).toBeCalledTimes(1);
expect(methodL).toHaveBeenNthCalledWith(1, "q");

Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/src/CustomTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class CustomTemplateRegistry {
string,
Function
>;
element[to.refMethod ?? from](...args);
return element[to.refMethod ?? from](...args);
},
enumerable: true,
});
Expand Down
Loading