forked from MrRefactoring/jira.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprojectVersions.test.ts
93 lines (71 loc) · 2.71 KB
/
projectVersions.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import * as sinon from 'sinon';
import { test } from 'vitest';
import { ProjectVersions, Version2Client } from '@jirajs/version2';
const config = { host: 'http://localhost' };
test('should be defined', ({ expect }) => {
expect(!!ProjectVersions).toBeTruthy();
});
test('getProjectVersionsPaginated should accept follow parameters', ({ expect }) => {
const client = new Version2Client(config);
const sendRequestStub = sinon.stub(client, 'sendRequest');
client.projectVersions.getProjectVersionsPaginated({
projectIdOrKey: 'StubProjectId',
maxResults: 50,
orderBy: '-sequence',
});
expect(sendRequestStub.calledOnce).toBeTruthy();
const callArgument = sendRequestStub.getCall(0).args[0];
expect(callArgument.url).toBe('/rest/api/2/project/StubProjectId/version');
expect(callArgument.params).toStrictEqual({
maxResults: 50,
orderBy: '-sequence',
expand: undefined,
query: undefined,
startAt: undefined,
status: undefined,
});
});
test('getVersionRelatedIssues should accept follow parameters', ({ expect }) => {
const client = new Version2Client(config);
const sendRequestStub = sinon.stub(client, 'sendRequest');
client.projectVersions.getVersionRelatedIssues({ id: 'RelatedIssueId' });
expect(sendRequestStub.calledOnce).toBeTruthy();
const callArgument = sendRequestStub.getCall(0).args[0];
expect(callArgument.url).toBe('/rest/api/2/version/RelatedIssueId/relatedIssueCounts');
});
test('getProjectVersions should accept follow parameters', ({ expect }) => {
const client = new Version2Client(config);
const sendRequestStub = sinon.stub(client, 'sendRequest');
client.projectVersions.getProjectVersions({ projectIdOrKey: 'TEST' });
expect(sendRequestStub.calledOnce).toBeTruthy();
const callArgument = sendRequestStub.getCall(0).args[0];
expect(callArgument.url).toBe('/rest/api/2/project/TEST/versions');
});
test('createVersion should accept follow parameters', ({ expect }) => {
const client = new Version2Client(config);
const sendRequestStub = sinon.stub(client, 'sendRequest');
client.projectVersions.createVersion({
projectId: 1455,
name: 'testName',
});
expect(sendRequestStub.calledOnce).toBeTruthy();
const callArgument = sendRequestStub.getCall(0).args[0];
expect(callArgument.data).toStrictEqual({
archived: undefined,
description: undefined,
expand: undefined,
id: undefined,
issuesStatusForFixVersion: undefined,
moveUnfixedIssuesTo: undefined,
name: 'testName',
operations: undefined,
overdue: undefined,
projectId: 1455,
releaseDate: undefined,
released: undefined,
self: undefined,
startDate: undefined,
userReleaseDate: undefined,
userStartDate: undefined,
});
});