Skip to content

Commit 54b0175

Browse files
committed
incremental fixes
1 parent ce2d3f5 commit 54b0175

File tree

2 files changed

+17
-84
lines changed

2 files changed

+17
-84
lines changed

tests/integration/agile/sprint.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ afterAll(async () => {
2121
await deleteAgileProject();
2222
});
2323

24-
test.sequential.skip('should create new sprint', async ({ expect }) => {
24+
test.sequential('should create new sprint', async ({ expect }) => {
2525
const boards = await client.board.getAllBoards({ name: Constants.testAgileProjectKey });
2626

2727
expect(boards.total).toBe(1);
@@ -40,7 +40,7 @@ test.sequential.skip('should create new sprint', async ({ expect }) => {
4040
expect(sprint.state).toBe('future');
4141
});
4242

43-
test.sequential.skip('should create and move task to sprint', async ({ expect }) => {
43+
test.sequential('should create and move task to sprint', async ({ expect }) => {
4444
const issue = await getVersion3Client().issues.createIssue({
4545
fields: {
4646
summary: 'Test task',
@@ -65,7 +65,7 @@ test.sequential.skip('should create and move task to sprint', async ({ expect })
6565
expect(!!issue).toBeTruthy();
6666
});
6767

68-
test.sequential.skip('should return issues for sprint', async ({ expect }) => {
68+
test.sequential('should return issues for sprint', async ({ expect }) => {
6969
const { issues } = await client.sprint.getIssuesForSprint({
7070
sprintId: sprint.id,
7171
});
@@ -74,7 +74,7 @@ test.sequential.skip('should return issues for sprint', async ({ expect }) => {
7474
expect(issues[0].fields?.summary).toBe('Test task');
7575
});
7676

77-
test.sequential.skip('should partially update sprint', async ({ expect }) => {
77+
test.sequential('should partially update sprint', async ({ expect }) => {
7878
const newSprint = await client.sprint.partiallyUpdateSprint({
7979
sprintId: sprint.id,
8080
state: 'active',
@@ -85,6 +85,6 @@ test.sequential.skip('should partially update sprint', async ({ expect }) => {
8585
expect(newSprint.state).toBe('active');
8686
});
8787

88-
test.sequential.skip('should remove sprint', async () => {
88+
test.sequential('should remove sprint', async () => {
8989
await client.sprint.deleteSprint({ sprintId: sprint.id });
9090
});

tests/unit/clients/baseClient.test.ts

Lines changed: 12 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,20 @@
1-
import * as sinon from 'sinon';
2-
import { test } from 'vitest';
1+
import { describe, test } from 'vitest';
32
import { BaseClient } from '@jirajs';
43

5-
const XAtlassianToken = 'X-Atlassian-Token';
4+
describe('BaseClient', () => {
5+
test('shouldn\'t display error message for correct host urls', () => {
6+
new BaseClient({
7+
host: 'http://localhost',
8+
});
69

7-
test('should create X-Atlassian-Token: no-check header in requests', async ({ expect }) => {
8-
const client = new BaseClient({
9-
host: 'http://localhost',
10-
noCheckAtlassianToken: true,
10+
new BaseClient({ host: 'https://localhost/' });
1111
});
1212

13-
// @ts-expect-error Wrong typings
14-
const defaultHeaders: Record<string, string> = client.instance.defaults.headers;
13+
test('should display error message for incorrect host url', ({ expect }) => {
14+
const errorMessage = 'Couldn\'t parse the host URL. Perhaps you forgot to add \'http://\' or \'https://\' at the beginning of the URL?';
1515

16-
expect(defaultHeaders[XAtlassianToken]).toBe('no-check');
17-
18-
const sendRequestStub = sinon.stub(client, 'sendRequest');
19-
20-
// @ts-expect-error Wrong typings
21-
await client.sendRequest({}, undefined); // TODO problem with never type
22-
23-
expect(sendRequestStub.calledOnce).toBeTruthy();
24-
25-
const callArgument = sendRequestStub.getCall(0).args[0];
26-
27-
expect(callArgument.headers?.[XAtlassianToken]).toBe(undefined);
28-
});
29-
30-
test('should not create X-Atlassian-Token: no-check header in requests case 1', async ({ expect }) => {
31-
const client = new BaseClient({
32-
host: 'http://localhost',
33-
noCheckAtlassianToken: false,
34-
});
35-
// @ts-expect-error Wrong typings
36-
const defaultHeaders: Record<string, string> = client.instance.defaults.headers;
37-
38-
expect(defaultHeaders[XAtlassianToken]).toBe(undefined);
39-
40-
const sendRequestStub = sinon.stub(client, 'sendRequest');
41-
42-
// @ts-expect-error Wrong typings
43-
await client.sendRequest({}, undefined); // TODO problem with never type
44-
expect(sendRequestStub.calledOnce).toBeTruthy();
45-
46-
const callArgument = sendRequestStub.getCall(0).args[0];
47-
48-
expect(callArgument.headers?.[XAtlassianToken]).toBe(undefined);
49-
});
50-
51-
test('should create X-Atlassian-Token: no-check header in requests case 2', async ({ expect }) => {
52-
const client = new BaseClient({
53-
host: 'http://localhost',
16+
expect(() => new BaseClient({ host: '' })).toThrowError(errorMessage);
17+
expect(() => new BaseClient({ host: 'localhost' })).toThrowError(errorMessage);
18+
expect(() => new BaseClient({ host: 'example.com' })).toThrowError(errorMessage);
5419
});
55-
56-
// @ts-expect-error Wrong typings
57-
const defaultHeaders: Record<string, string> = client.instance.defaults.headers;
58-
59-
expect(defaultHeaders[XAtlassianToken]).toBe(undefined);
60-
61-
const sendRequestStub = sinon.stub(client, 'sendRequest');
62-
63-
// @ts-expect-error Wrong typings
64-
await client.sendRequest({}, undefined); // TODO problem with never type
65-
66-
expect(sendRequestStub.calledOnce).toBeTruthy();
67-
68-
const callArgument = sendRequestStub.getCall(0).args[0];
69-
70-
expect(callArgument.headers?.[XAtlassianToken]).toBe(undefined);
71-
});
72-
73-
test('shouldn\'t display error message for correct host urls', () => {
74-
new BaseClient({
75-
host: 'http://localhost',
76-
});
77-
78-
new BaseClient({ host: 'https://localhost/' });
79-
});
80-
81-
test('should display error message for incorrect host url', ({ expect }) => {
82-
const errorMessage = 'Couldn\'t parse the host URL. Perhaps you forgot to add \'http://\' or \'https://\' at the beginning of the URL?';
83-
84-
expect(() => new BaseClient({ host: '' })).toThrowError(errorMessage);
85-
expect(() => new BaseClient({ host: 'localhost' })).toThrowError(errorMessage);
86-
expect(() => new BaseClient({ host: 'example.com' })).toThrowError(errorMessage);
8720
});

0 commit comments

Comments
 (0)