You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

23 lines
600 B

import { AbstractMethodMap } from "../../src";
class TestMap extends AbstractMethodMap<{ doSomething(a: number, b: number): number }> {
public mockFn = jest.fn();
public methodMap = {
doSomething: this.doSomething
};
public doSomething(a: number, b: number) {
this.mockFn(); // Ensure the correct 'this' context
return a + b;
}
public publicInvoke() {
this.invoke("doSomething", [5, 10]);
}
}
describe("Abstract Method Map", () => {
it("Invoke mapped method", () => {
let map = new TestMap();
map.invoke("doSomething", [5, 10]);
expect(map.mockFn).toHaveBeenCalled()
});
});