forked from MrRefactoring/jira.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathissueVotes.test.ts
45 lines (34 loc) · 1.28 KB
/
issueVotes.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { afterAll, beforeAll, test } from 'vitest';
import type { CreatedIssue } from '@jirajs/version3/models';
import {
cleanupEnvironment,
createIssue,
getVersion3Client,
prepareEnvironment,
} from '@tests/integration/utils';
const client = getVersion3Client();
let createdIssue: CreatedIssue;
beforeAll(async () => {
await prepareEnvironment();
createdIssue = await createIssue();
});
afterAll(async () => {
await cleanupEnvironment();
});
test.sequential('should get zero votes on the issue', async ({ expect }) => {
const { votes, hasVoted } = await client.issueVotes.getVotes({ issueIdOrKey: createdIssue.id });
expect(votes).toBe(0);
expect(hasVoted).toBeFalsy();
});
test.sequential('should add vote to issue', async ({ expect }) => {
await client.issueVotes.addVote({ issueIdOrKey: createdIssue.key });
const { votes, hasVoted } = await client.issueVotes.getVotes({ issueIdOrKey: createdIssue.id });
expect(votes).toBe(1);
expect(hasVoted).toBeTruthy();
});
test.sequential('should remove vote from issue', async ({ expect }) => {
await client.issueVotes.removeVote({ issueIdOrKey: createdIssue.key });
const { votes, hasVoted } = await client.issueVotes.getVotes({ issueIdOrKey: createdIssue.id });
expect(votes).toBe(0);
expect(hasVoted).toBeFalsy();
});