test: add test case for findById

This commit is contained in:
2025-12-20 23:41:31 -03:00
parent 5e4adedd27
commit e1b1f6d743

View File

@@ -43,6 +43,17 @@ describe('ContactService', () => {
httpTestingController.verify(); httpTestingController.verify();
}); });
it('should GET contacts from the contacts ep with the given ID', () => {
const ID_MOCK = 1;
const url = `${endpointURL}/${ID_MOCK}`;
service.findById(String(ID_MOCK)).subscribe();
const req = httpTestingController.expectOne(url);
expect(req.request.method).toEqual('GET');
RES_MOCK.data = new ContactDTO(1, 'mock', 'mock', 'mock');
req.flush(RES_MOCK);
httpTestingController.verify();
});
it('should POST contact to the contacts ep', () => { it('should POST contact to the contacts ep', () => {
const CONTACT_MOCK = new ContactDTO(undefined, 'mock'); const CONTACT_MOCK = new ContactDTO(undefined, 'mock');
service.save(CONTACT_MOCK).subscribe(); service.save(CONTACT_MOCK).subscribe();