Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getMockUser(auth: StitchAuthImpl) {
return new StitchUserImpl(
"test_id",
"test_provider",
"test_provider",
true,
new Date(),
instance(mock(StitchUserProfileImpl)),
auth
)
}
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
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
{ provide: PersonalizationService, useFactory: () => instance(mock(PersonalizationService)) },
],
providers: [{ provide: Store, useFactory: () => instance(mock(Store)) }],
}).compileComponents();
{ provide: Store, useFactory: () => instance(store$) },
],
{ provide: ActivatedRoute, useFactory: () => instance(this.mockedActivatedRoute) },
{ provide: IdentityService, useFactory: () => instance(this.mockedIdentityService) },
{ provide: ProductCompareService, useFactory: () => instance(productCompareServiceMock) }
]
beforeEach(() => {
apiService = mock(ApiService);
when(apiService.icmServerURL).thenReturn('http://server');
addressService = new AddressService(instance(apiService));
});
{ provide: IdentityService, useFactory: () => instance(this.mockedIdentityService) },
{ provide: ActivatedRoute, useFactory: () => instance(this.mockedActivatedRoute) },