export class Test {
constructor() {}
private testPri(a: string): string {
return a + 'test';
}
}
describe("Test", () => {
it("test private function", async () => {
const test = new Test();
const r = test["testPri"]("a");
expect(r).toBe("atest");
});
it("mock private function", async () => {
const test = new Test();
jest.spyOn(test as any, "testPri").mockReturnValue("token");
const r = test["testPri"]("a");
expect(r).toBe("token");
});
});