Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
add tests for two new ranked choice functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler17 committed May 28, 2020
1 parent 02e6182 commit a8b2abd
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion packages/dai-plugin-governance/test/GovPollingService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ test('getMkrAmtVoted', async () => {
expect(total).toEqual(MKR(160));
});

test('getMkrAmtVotedRankedChoice', async () => {
govQueryApiService.getMkrSupportRankedChoice = jest.fn(
() => dummyBallotWithMajority
);
govPollingService._getPoll = jest.fn(() => ({
endDate: 123
}));
const amount = await govPollingService.getMkrAmtVotedRankedChoice();
expect(amount.toNumber()).toBe(
parseFloat(dummyBallotWithMajorityExpect.totalMkrParticipation)
);
});

test('getOptionVotingFor', async () => {
const mockFn = jest.fn(async () => dummyOption);
govQueryApiService.getOptionVotingFor = mockFn;
Expand Down Expand Up @@ -147,6 +160,26 @@ test('getPercentageMkrVoted', async () => {
expect(percentage).toBe(40);
});

test('getPercentageMkrVotedRankedChoice', async () => {
govQueryApiService.getMkrSupportRankedChoice = jest.fn(
() => dummyBallotWithMajority
);
govPollingService._getPoll = jest.fn(() => ({
endDate: 123
}));
const percentage = await govPollingService.getPercentageMkrVotedRankedChoice();
const mkrSupply = await maker
.service('token')
.getToken(MKR)
.totalSupply();
expect(percentage).toBe(
MKR(dummyBallotWithMajorityExpect.totalMkrParticipation)
.div(mkrSupply.toNumber())
.times(100)
.toNumber()
);
});

test('ranked choice tally with majority', async () => {
govQueryApiService.getMkrSupportRankedChoice = jest.fn(
() => dummyBallotWithMajority
Expand Down Expand Up @@ -175,7 +208,7 @@ test('ranked choice tally with no majority', async () => {
);
});

test.only('ranked choice tally with multiple rounds', async () => {
test('ranked choice tally with multiple rounds', async () => {
govQueryApiService.getMkrSupportRankedChoice = jest.fn(
() => dummyBallotMultipleRounds
);
Expand Down

0 comments on commit a8b2abd

Please sign in to comment.