-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/makerdao/governance-port…
…al-v2 into chore/sc-481/update-categories-in-the-validator-function
- Loading branch information
Showing
3 changed files
with
128 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { Poll } from '../../types'; | ||
import { sortPolls } from '../parsePollMetadata'; | ||
|
||
describe('Parse poll metadata', () => { | ||
const polls: Poll[] = [ | ||
{ | ||
categories: ['a'], | ||
content: '', | ||
discussionLink: '', | ||
endDate: new Date(2011, 10, 30), | ||
multiHash: '', | ||
options: {}, | ||
pollId: 1, | ||
startDate: new Date(2011, 10, 30), | ||
slug: '', | ||
summary: '', | ||
title: '2011,10,30', | ||
voteType: 'Plurality Voting', | ||
ctx: {} as any | ||
}, | ||
{ | ||
categories: ['a'], | ||
content: '', | ||
discussionLink: '', | ||
endDate: new Date(2011, 10, 30), | ||
multiHash: '', | ||
options: {}, | ||
pollId: 2, | ||
startDate: new Date(2011, 10, 31), | ||
slug: '', | ||
summary: '', | ||
title: '2011,10,31', | ||
voteType: 'Plurality Voting', | ||
ctx: {} as any | ||
}, | ||
{ | ||
categories: ['a'], | ||
content: '', | ||
discussionLink: '', | ||
endDate: new Date(2021, 10, 31), | ||
multiHash: '', | ||
options: {}, | ||
pollId: 3, | ||
startDate: new Date(2021, 10, 31), | ||
slug: '', | ||
summary: '', | ||
title: '2021,10,31', | ||
voteType: 'Plurality Voting', | ||
ctx: {} as any | ||
}, | ||
{ | ||
categories: ['a'], | ||
content: '', | ||
discussionLink: '', | ||
endDate: new Date(2021, 11, 31), | ||
multiHash: '', | ||
options: {}, | ||
pollId: 4, | ||
startDate: new Date(2021, 11, 31), | ||
slug: '', | ||
summary: '', | ||
title: '2021,11,31', | ||
voteType: 'Plurality Voting', | ||
ctx: {} as any | ||
} | ||
]; | ||
|
||
test('The first poll is the one ending sooner', () => { | ||
const results = sortPolls(polls); | ||
|
||
expect(results[0].pollId).toEqual(2); | ||
}); | ||
|
||
test('The second poll is the one with the same date as 1 but different start date', () => { | ||
const results = sortPolls(polls); | ||
|
||
expect(results[1].pollId).toEqual(1); | ||
}); | ||
|
||
test('The 4 poll is the one ending later', () => { | ||
const results = sortPolls(polls); | ||
|
||
expect(results[3].pollId).toEqual(4); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters