Skip to content

Commit 3d6948f

Browse files
author
Lucas Araujo
committed
[DDW-796] VotingStore unit test
1 parent 919aa78 commit 3d6948f

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// @flow
2+
import type { Api } from '../api/index';
3+
import type { ActionsMap } from '../actions/index';
4+
import VotingStore, { FundPhases } from './VotingStore';
5+
import {
6+
VOTING_CAST_END_DATE,
7+
VOTING_CAST_START_DATE,
8+
VOTING_RESULTS_DATE,
9+
VOTING_SNAPSHOT_DATE,
10+
} from '../config/votingConfig';
11+
12+
describe('VotingStore', () => {
13+
const api: Api = ({
14+
ada: jest.fn(),
15+
}: any);
16+
17+
const actions: ActionsMap = (jest.fn(): any);
18+
19+
const cases = [
20+
[new Date(VOTING_SNAPSHOT_DATE.getTime() - 60000), FundPhases.SNAPSHOT],
21+
[VOTING_SNAPSHOT_DATE, FundPhases.SNAPSHOT],
22+
[new Date(VOTING_CAST_START_DATE.getTime() - 60000), FundPhases.SNAPSHOT],
23+
[VOTING_CAST_START_DATE, FundPhases.VOTING],
24+
[new Date(VOTING_CAST_END_DATE.getTime() - 60000), FundPhases.VOTING],
25+
[VOTING_CAST_END_DATE, FundPhases.TALLYING],
26+
[new Date(VOTING_RESULTS_DATE.getTime() - 60000), FundPhases.TALLYING],
27+
[VOTING_RESULTS_DATE, FundPhases.RESULTS],
28+
];
29+
30+
test.each(cases)(
31+
`should have correct fund phase for date %s - %s phase`,
32+
(date, expected) => {
33+
const votingStore = new VotingStore(api, actions);
34+
35+
votingStore._checkFundPhase(date);
36+
37+
expect(votingStore.fundPhase).toEqual(expected);
38+
}
39+
);
40+
});

0 commit comments

Comments
 (0)