Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(() => {
verify(requestClientMock.doRequest(anything())).times(1);
const [requestArg] = capture(requestClientMock.doRequest).last();
expect(expectedRequest).toEqualRequest(requestArg);
// Should pass along errors
when(requestClientMock.doRequest(anything())).thenThrow(
new Error("whoops")
);
return expect(fun(client));
})
.catch(err => {
.then(() => {
verify(requestClientMock.doAuthenticatedRequest(anything())).times(1);
const [requestArg] = capture(
requestClientMock.doAuthenticatedRequest
).last();
expect(expectedRequest).toEqualRequest(requestArg);
// Should pass along errors
when(requestClientMock.doAuthenticatedRequest(anything())).thenThrow(
new Error("whoops")
);
return fun(client);
})
.catch((err: Error) => {
it('should throw updateSubmitQuoteRequest event when submit is clicked and the form values were changed before ', () => {
const emitter = spy(component.updateSubmitQuoteRequest);
component.form.value.displayName = 'DNAME';
component.form.value.description = 'DESC';
component.form.markAsDirty();
component.submit();
verify(emitter.emit(anything())).once();
const [arg] = capture(emitter.emit).last();
expect(arg).toMatchInlineSnapshot(`
Object {
"description": "DESC",
"displayName": "DNAME",
}
`);
});
});
it('should remove binding', () => {
component.ngOnDestroy();
const [hotkey] = capture(hotkeyServiceMock.remove).last();
expect((hotkey as Hotkey).combo).toEqual(['del']);
});
export function logApiCalls(apiServiceMock: ApiService) {
for (let i = 0; i < 100; i++) {
try {
const args = capture(apiServiceMock.get).byCallIndex(i);
console.log('GET', args);
} catch (err) {
break;
}
}
for (let i = 0; i < 100; i++) {
try {
const args = capture(apiServiceMock.post).byCallIndex(i);
console.log('POST', args);
} catch (err) {
break;
}
}
for (let i = 0; i < 100; i++) {
try {
const args = capture(apiServiceMock.put).byCallIndex(i);
console.log('PUT', args);
} catch (err) {
break;
}
}
}
it('clicking submit calls library, shows notice, goes /projects', fakeAsync(() => {
const newPassword = 'aaaaaaa';
env.newPasswordControl.setValue(newPassword);
env.confirmPasswordControl.setValue(newPassword);
env.fixture.detectChanges();
env.clickSubmit();
verify(env.mockedUserService.onlineChangePassword(anyString())).once();
const arg = capture(env.mockedUserService.onlineChangePassword).last()[0];
expect(arg).toEqual(newPassword);
verify(env.mockedNoticeService.show(anyString())).once();
verify(env.mockedRouter.navigateByUrl(anyString())).once();
const routerArg = capture(env.mockedRouter.navigateByUrl).last()[0];
expect(routerArg).toEqual('/projects');
}));
console.log('GET', args);
} catch (err) {
break;
}
}
for (let i = 0; i < 100; i++) {
try {
const args = capture(apiServiceMock.post).byCallIndex(i);
console.log('POST', args);
} catch (err) {
break;
}
}
for (let i = 0; i < 100; i++) {
try {
const args = capture(apiServiceMock.put).byCallIndex(i);
console.log('PUT', args);
} catch (err) {
break;
}
}
}
effects.updateBasketItems$.subscribe(() => {
verify(basketServiceMock.updateBasketItem('BID', payload.lineItemUpdates[1].itemId, anything())).thrice();
expect(capture(basketServiceMock.updateBasketItem).first()).toMatchInlineSnapshot(`
Array [
"BID",
"BIID",
Object {
"product": undefined,
"quantity": Object {
"unit": undefined,
"value": 2,
},
},
]
`);
expect(capture(basketServiceMock.updateBasketItem).second()).toMatchInlineSnapshot(`
Array [
"BID",
"BIID",
orderService.getOrderByToken('id12345', 'dummy').subscribe(data => {
verify(apiService.get(anything(), anything())).once();
const [path, options] = capture(apiService.get).last();
expect(path).toEqual('orders/id12345');
expect(options.headers.get(ApiService.TOKEN_HEADER_KEY)).toEqual('dummy');
expect(data).toHaveProperty('id', 'id12345');
done();
});
});
effects.setLocale$.subscribe(() => {
verify(translateServiceMock.use(anything())).once();
const params = capture(translateServiceMock.use).last();
expect(params[0]).toEqual('en_US');
done();
});