chore: finishing unit tests for a couple of services (#13292)
This commit is contained in:
@@ -3,15 +3,18 @@ import { IPartnerRepository, PartnerDirection } from 'src/interfaces/partner.int
|
||||
import { PartnerService } from 'src/services/partner.service';
|
||||
import { authStub } from 'test/fixtures/auth.stub';
|
||||
import { partnerStub } from 'test/fixtures/partner.stub';
|
||||
import { IAccessRepositoryMock } from 'test/repositories/access.repository.mock';
|
||||
import { newTestService } from 'test/utils';
|
||||
import { Mocked } from 'vitest';
|
||||
|
||||
describe(PartnerService.name, () => {
|
||||
let sut: PartnerService;
|
||||
|
||||
let accessMock: IAccessRepositoryMock;
|
||||
let partnerMock: Mocked<IPartnerRepository>;
|
||||
|
||||
beforeEach(() => {
|
||||
({ sut, partnerMock } = newTestService(PartnerService));
|
||||
({ sut, accessMock, partnerMock } = newTestService(PartnerService));
|
||||
});
|
||||
|
||||
it('should work', () => {
|
||||
@@ -71,4 +74,24 @@ describe(PartnerService.name, () => {
|
||||
expect(partnerMock.remove).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('update', () => {
|
||||
it('should require access', async () => {
|
||||
await expect(sut.update(authStub.admin, 'shared-by-id', { inTimeline: false })).rejects.toBeInstanceOf(
|
||||
BadRequestException,
|
||||
);
|
||||
});
|
||||
|
||||
it('should update partner', async () => {
|
||||
accessMock.partner.checkUpdateAccess.mockResolvedValue(new Set(['shared-by-id']));
|
||||
partnerMock.update.mockResolvedValue(partnerStub.adminToUser1);
|
||||
|
||||
await expect(sut.update(authStub.admin, 'shared-by-id', { inTimeline: true })).resolves.toBeDefined();
|
||||
expect(partnerMock.update).toHaveBeenCalledWith({
|
||||
sharedById: 'shared-by-id',
|
||||
sharedWithId: authStub.admin.user.id,
|
||||
inTimeline: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user