Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
af-egr committed Jan 28, 2025
1 parent 8f2e3f6 commit be18b8a
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/modules/proposal/utils/__tests__/add-location-vote.util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { ConditionalApproval } from '../../schema/sub-schema/conditional-approva
import { addFdpgTaskAndReturnId, removeFdpgTask } from '../add-fdpg-task.util';
import {
addDizApproval,
addUacApproval,
addDizConditionApproval,
addUacApprovalWithCondition,
addUacConditionReview,
addDizConditionReview,
} from '../add-location-vote.util';
import { clearLocationsVotes } from '../location-flow.util';

Expand Down Expand Up @@ -59,6 +59,7 @@ describe('addLocationVoteUtil', () => {
dizApprovedLocations: [],
requestedButExcludedLocations: [],
uacApprovedLocations: [],
openDizConditionChecks: [],
uacApprovals: [],
declineReasons: [],
};
Expand Down Expand Up @@ -112,14 +113,14 @@ describe('addLocationVoteUtil', () => {
const upload = {
_id: 'uploadId',
} as any as UploadDto;
addUacApprovalWithCondition(proposal, request.user.miiLocation, upload, vote);
addUacApprovalWithCondition(proposal, request.user, vote, upload);

expect(clearLocationsVotes).toBeCalledWith(proposal, request.user.miiLocation);
expect(proposal.uacApprovedLocations).toEqual([request.user.miiLocation]);
expect(proposal.conditionalApprovals.length).toEqual(1);
expect(proposal.conditionalApprovals[0].location).toEqual(request.user.miiLocation);
expect(proposal.conditionalApprovals[0].dataAmount).toEqual(vote.dataAmount);
expect(proposal.conditionalApprovals[0].isContractSigned).toEqual(false);
expect(proposal.openDizConditionChecks).toEqual([request.user.miiLocation]);
expect(proposal.locationConditionDraft.length).toEqual(1);
expect(proposal.locationConditionDraft[0].location).toEqual(request.user.miiLocation);
expect(proposal.locationConditionDraft[0].dataAmount).toEqual(vote.dataAmount);
expect(proposal.locationConditionDraft[0].isContractSigned).toEqual(false);
});

it('should add the uac decline', () => {
Expand All @@ -134,12 +135,12 @@ describe('addLocationVoteUtil', () => {
const upload = {
_id: 'uploadId',
} as any as UploadDto;
addUacApprovalWithCondition(proposal, request.user.miiLocation, upload, vote);
addUacApprovalWithCondition(proposal, request.user, vote, upload);

expect(clearLocationsVotes).toBeCalledWith(proposal, request.user.miiLocation);
expect(addFdpgTaskAndReturnId).toBeCalledWith(proposal, FdpgTaskType.UacApprovalComplete);

expect(proposal.uacApprovedLocations).not.toEqual([request.user.miiLocation]);
expect(proposal.openDizConditionChecks).not.toEqual([request.user.miiLocation]);
expect(proposal.requestedButExcludedLocations).toEqual([request.user.miiLocation]);
});
});
Expand All @@ -152,14 +153,15 @@ describe('addLocationVoteUtil', () => {
vote.value = true;
vote.dataAmount = 100;

addUacApproval(proposal, request.user, vote);
addDizConditionApproval(proposal, request.user, vote);

expect(clearLocationsVotes).toBeCalledWith(proposal, request.user.miiLocation);
expect(proposal.uacApprovedLocations).toEqual([request.user.miiLocation]);
expect(proposal.uacApprovals.length).toEqual(1);
expect(proposal.openDizConditionChecks).toEqual([]);
expect(proposal.openDizConditionChecks.length).toEqual(0);
expect(proposal.uacApprovals[0].location).toEqual(request.user.miiLocation);
expect(proposal.uacApprovals[0].dataAmount).toEqual(vote.dataAmount);
expect(proposal.uacApprovals[0].isContractSigned).toEqual(false);
expect(proposal.locationConditionDraft?.length ?? 0).toEqual(0);
expect(proposal.totalPromisedDataAmount).toEqual(vote.dataAmount);
});

Expand All @@ -171,7 +173,7 @@ describe('addLocationVoteUtil', () => {
vote.value = false;
vote.declineReason = 'declineReason';

addUacApproval(proposal, request.user, vote);
addDizConditionApproval(proposal, request.user, vote);

expect(clearLocationsVotes).toBeCalledWith(proposal, request.user.miiLocation);
expect(addFdpgTaskAndReturnId).toBeCalledWith(proposal, FdpgTaskType.UacApprovalComplete);
Expand All @@ -195,7 +197,7 @@ describe('addLocationVoteUtil', () => {
condition.fdpgTaskId = 'taskId';
condition.dataAmount = 100;

addUacConditionReview(proposal, condition, vote, request.user);
addDizConditionReview(proposal, condition, vote, request.user);

expect(clearLocationsVotes).toBeCalledWith(proposal, condition.location);
expect(removeFdpgTask).toBeCalledWith(proposal, condition.fdpgTaskId);
Expand All @@ -218,7 +220,7 @@ describe('addLocationVoteUtil', () => {
condition.fdpgTaskId = 'taskId';
condition.dataAmount = 100;

addUacConditionReview(proposal, condition, vote, request.user);
addDizConditionReview(proposal, condition, vote, request.user);

expect(clearLocationsVotes).toBeCalledWith(proposal, condition.location);
expect(removeFdpgTask).toBeCalledWith(proposal, condition.fdpgTaskId);
Expand Down

0 comments on commit be18b8a

Please sign in to comment.