You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Injectable()classFoo{mockedFunction(){returnfalse}}
@Injectable()classTest{constructor(privatereadonlyfoo: Foo){}testInjection(){returnthis.foo.mockedFunction()}}constFooMock={mockedFunction: jest.fn(()=>true)}describe("Should test injection pattern",()=>{letuseTest: Test;beforeEach(()=>{Injector.container.clear()Injector.mock("Foo",FooMock)useTest=Injector.resolve(Test)jest.clearAllMocks()})it("Should Test class exist",()=>{expect(useTest).toBeTruthy()})it("Should call mocked function inject via dependency",()=>{useTest.testInjection()expect(FooMock.mockedFunction).toHaveBeenCalled()})})