Skip to content

Commit

Permalink
[ADD] proposal upload service
Browse files Browse the repository at this point in the history
  • Loading branch information
af-ofr committed Apr 29, 2024
1 parent 4d5d144 commit eb4fd67
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { StatusChangeService } from '../status-change.service';
import { ForbiddenException, NotFoundException } from '@nestjs/common';
import { NoErrorThrownError, getError } from 'test/get-error';
import { InitContractingDto } from '../../dto/proposal/init-contracting.dto';
import { ProposalUploadService } from '../proposal-upload.service';

jest.mock('class-transformer', () => {
const original = jest.requireActual('class-transformer');
Expand Down Expand Up @@ -94,6 +95,7 @@ describe('ProposalContractingService', () => {
let eventEngineService: jest.Mocked<EventEngineService>;
let storageService: jest.Mocked<StorageService>;
let statusChangeService: jest.Mocked<StatusChangeService>;
let proposalUploadService: jest.Mocked<ProposalUploadService>;

const request = {
user: {
Expand Down Expand Up @@ -161,6 +163,12 @@ describe('ProposalContractingService', () => {
handleEffects: jest.fn(),
},
},
{
provide: ProposalUploadService,
useValue: {
handleEffects: jest.fn(),
},
},
],
imports: [],
}).compile();
Expand All @@ -170,6 +178,9 @@ describe('ProposalContractingService', () => {
eventEngineService = module.get<EventEngineService>(EventEngineService) as jest.Mocked<EventEngineService>;
storageService = module.get<StorageService>(StorageService) as jest.Mocked<StorageService>;
statusChangeService = module.get<StatusChangeService>(StatusChangeService) as jest.Mocked<StatusChangeService>;
proposalUploadService = module.get<ProposalUploadService>(
ProposalUploadService,
) as jest.Mocked<ProposalUploadService>;
});

it('should be defined', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ProposalUploadService } from './proposal-upload.service';
import { ForbiddenException, Injectable, NotFoundException } from '@nestjs/common';
import { plainToClass } from 'class-transformer';
import { isNotEmptyObject } from 'class-validator';
import { Role } from 'src/shared/enums/role.enum';
import { IRequestUser } from 'src/shared/types/request-user.interface';
import { convertUserToGroups } from 'src/shared/utils/user-group.utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ describe('addLocationVoteUtil', () => {
expect(proposal.uacApprovals.length).toEqual(0);
expect(proposal.uacApprovals).not.toEqual([uacApproval]);
expect(clearLocationsVotes).toBeCalledWith(proposal, uacApproval.location);
expect(proposal.requestedButExcludedLocations).not.toEqual([request.user.miiLocation]);
expect(proposal.uacApprovedLocations).not.toEqual([request.user.miiLocation]);
expect(proposal.openDizChecks).toEqual([uacApproval.location]);
});

Expand Down Expand Up @@ -354,7 +354,7 @@ describe('addLocationVoteUtil', () => {
expect(removeFdpgTask).toBeCalledWith(proposal, FdpgTaskType.DataAmountReached);
}
expect(clearLocationsVotes).toBeCalledWith(proposal, condition.location);
expect(proposal.requestedButExcludedLocations).not.toEqual([request.user.miiLocation]);
expect(proposal.uacApprovedLocations).not.toEqual([request.user.miiLocation]);
expect(proposal.openDizChecks).toEqual([condition.location]);
});
});
Expand Down Expand Up @@ -383,7 +383,7 @@ describe('addLocationVoteUtil', () => {
expect(removeFdpgTask).toBeCalledWith(proposal, condition.fdpgTaskId);
expect(proposal.conditionalApprovals).not.toEqual([condition]);
expect(clearLocationsVotes).toBeCalledWith(proposal, condition.location);
expect(proposal.requestedButExcludedLocations).not.toEqual([request.user.miiLocation]);
expect(proposal.uacApprovedLocations).not.toEqual([request.user.miiLocation]);
expect(proposal.openDizChecks).toEqual([condition.location]);
});

Expand All @@ -406,7 +406,7 @@ describe('addLocationVoteUtil', () => {
expect(proposalUploadServiceMock.deleteUpload).toBeCalledTimes(1);
expect(proposalUploadServiceMock.deleteUpload).toBeCalledWith(proposal._id, condition.uploadId, request.user);
expect(clearLocationsVotes).toBeCalledWith(proposal, condition.location);
expect(proposal.requestedButExcludedLocations).not.toEqual([request.user.miiLocation]);
expect(proposal.uacApprovedLocations).not.toEqual([request.user.miiLocation]);
expect(proposal.openDizChecks).toEqual([condition.location]);
});
});
Expand Down

0 comments on commit eb4fd67

Please sign in to comment.