How to use the ts-mockito.instance 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 / browser / coretest / __tests__ / auth / StitchAuthImplUnitTests.ts View on Github external
function getMockUser(auth: StitchAuthImpl) {
    return new StitchUserImpl(
        "test_id", 
        "test_provider", 
        "test_provider",
        true,
        new Date(),
        instance(mock(StitchUserProfileImpl)),
        auth
    )
}
github mongodb / stitch-js-sdk / packages / core / sdk / __tests__ / auth / providers / userapikey / CoreUserApiKeyAuthProviderClientUnitTests.ts View on Github external
function testClientCall(
  fun: (CoreUserApiKeyAuthProviderClient) => Promise,
  expectedRequest: StitchAuthRequest,
  keyToFetch?: string
): Promise {
  const clientAppId = "my_app-12345";

  const requestClientMock = mock(CoreStitchAuth);
  const requestClient = instance(requestClientMock);

  const routes = new StitchAppRoutes(clientAppId).authRoutes;

  const client = new CoreUserApiKeyAuthProviderClient(requestClient, routes);

  when(
    requestClientMock.doAuthenticatedRequest(new RequestClassMatcher(
      undefined,
      Method.POST
    ) as any)
  ).thenResolve({
    body: JSON.stringify(
      new UserApiKey(new BSON.ObjectID().toHexString(), "2", "3", false)
    ),
    headers: {},
    statusCode: 200
github mongodb / stitch-js-sdk / packages / core / sdk / __tests__ / auth / providers / userapikey / CoreUserApiKeyAuthProviderClientUnitTests.ts View on Github external
function testClientCall(
  fun: (CoreUserApiKeyAuthProviderClient) => Promise,
  expectedRequest: StitchAuthRequest,
  keyToFetch?: string
): Promise {
  const clientAppId = "my_app-12345";

  const requestClientMock = mock(CoreStitchAuth);
  const requestClient = instance(requestClientMock);

  const routes = new StitchAppRoutes(clientAppId).authRoutes;

  const client = new CoreUserApiKeyAuthProviderClient(requestClient, routes);

  when(
    requestClientMock.doAuthenticatedRequest(new RequestClassMatcher(
      undefined,
      Method.POST
    ) as any)
  ).thenResolve({
    body: JSON.stringify(
      new UserApiKey(new BSON.ObjectID().toHexString(), "2", "3", false)
    ),
    headers: {},
    statusCode: 200
github intershop / intershop-pwa / src / app / core / store / user / user.effects.spec.ts View on Github external
        { provide: PersonalizationService, useFactory: () => instance(mock(PersonalizationService)) },
      ],
github intershop / intershop-pwa / src / app / pages / recently / recently-page.container.spec.ts View on Github external
      providers: [{ provide: Store, useFactory: () => instance(mock(Store)) }],
    }).compileComponents();
github sillsdev / web-languageforge / src / SIL.XForge.Scripture / ClientApp / src / identity / verify-email / verify-email.component.spec.ts View on Github external
        { provide: ActivatedRoute, useFactory: () => instance(this.mockedActivatedRoute) },
        { provide: IdentityService, useFactory: () => instance(this.mockedIdentityService) },
github intershop / intershop-pwa / src / app / shopping / directives / disable-icon.directive.spec.ts View on Github external
      { provide: ProductCompareService, useFactory: () => instance(productCompareServiceMock) }
      ]
github intershop / intershop-pwa / src / app / core / services / address / address.service.spec.ts View on Github external
beforeEach(() => {
    apiService = mock(ApiService);
    when(apiService.icmServerURL).thenReturn('http://server');
    addressService = new AddressService(instance(apiService));
  });
github sillsdev / web-languageforge / src / SIL.XForge.Scripture / ClientApp / src / identity / external-sign-up / external-sign-up.component.spec.ts View on Github external
        { provide: IdentityService, useFactory: () => instance(this.mockedIdentityService) },
        { provide: ActivatedRoute, useFactory: () => instance(this.mockedActivatedRoute) },