How to use the ts-mockito.anyOfClass function in ts-mockito

To help you get started, we’ve selected a few ts-mockito examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mongodb / stitch-js-sdk / packages / core / sdk / __tests__ / services / internal / CoreStitchServiceUnitTests.ts View on Github external
it("should call function", () => {
    const serviceName = "svc1";
    const routes = new StitchServiceRoutes("foo");

    const requestClientMock = mock(CoreStitchAuth);

    when(
      requestClientMock.doAuthenticatedRequestWithDecoder(
        anyOfClass(StitchAuthRequest),
        anything()
      )
    ).thenReturn(Promise.resolve(42));

    const requestClient: StitchAuthRequestClient = instance(requestClientMock);

    const coreStitchService = new CoreStitchServiceClientImpl(
      requestClient,
      routes,
      serviceName
    );

    const funcName = "myFunc1";
    const args = [1, 2, 3];
    const expectedRequestDoc = {
      arguments: args,
github mongodb / stitch-js-sdk / packages / core / sdk / __tests__ / services / internal / CoreStitchServiceUnitTests.ts View on Github external
const spiedBinder1 = spy(binder1);
    const spiedBinder2 = spy(binder2);

    underTest.bind(binder1);
    underTest.bind(binder2);

    const event = new AuthRebindEvent({
      currentActiveUser: undefined,
      kind: AuthEventKind.ActiveUserChanged,
      previousActiveUser: undefined,
    });

    underTest.onRebindEvent(event);

    verify(spiedBinder2.onRebindEvent(anyOfClass(AuthRebindEvent))).called();
    verify(spiedBinder1.onRebindEvent(anyOfClass(AuthRebindEvent))).called();
  });
github typetron / framework / test / Database / Query.ts View on Github external
before() {
        const connection = mock(Connection);
        Query.connection = instance(connection);
        when(connection.get(anyOfClass(Query))).thenCall((query: Query) => {
            return query.toSql();
        });
        this.query = new Query;
    }
github typetron / framework / test / Database / Entity.ts View on Github external
async selectsEverything() {
        when(this.connection.get(anyOfClass(Query))).thenReturn(Promise.resolve(Object.values(this.data)));
        const users = await User.get();
        this.expectToContain(users[0], this.data.user1);
    }