Skip to content

Commit

Permalink
Move helpers to GitHubOrg
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Jul 25, 2023
1 parent a399674 commit a1f6699
Show file tree
Hide file tree
Showing 12 changed files with 310 additions and 388 deletions.
88 changes: 0 additions & 88 deletions src/api/github/helpers.test.ts

This file was deleted.

223 changes: 0 additions & 223 deletions src/api/github/helpers.ts

This file was deleted.

79 changes: 79 additions & 0 deletions src/api/github/org.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,82 @@ describe('bindAPI', function () {
});
});
});

describe('helpers', function () {
const org = GETSENTRY_ORG;

it('addIssueToGlobalIssuesProject should return project item id from project', async function () {
org.api = {
graphql: jest
.fn()
.mockReturnValue({ addProjectV2ItemById: { item: { id: '12345' } } }),
};
expect(
await org.addIssueToGlobalIssuesProject('issueNodeId', 'test-repo', 1)
).toEqual('12345');
});

it('getAllProjectFieldNodeIds should return timestamp from project', async function () {
org.api = {
graphql: jest.fn().mockReturnValue({
node: {
options: [
{ name: 'Waiting for: Product Owner', id: 1 },
{ name: 'Waiting for: Support', id: 2 },
{ name: 'Waiting for: Community', id: 3 },
],
},
}),
};
expect(await org.getAllProjectFieldNodeIds('projectFieldId')).toEqual({
'Waiting for: Product Owner': 1,
'Waiting for: Support': 2,
'Waiting for: Community': 3,
});
});

it('getKeyValueFromProjectField should return timestamp from project', async function () {
org.api = {
graphql: jest.fn().mockReturnValue({
node: { fieldValueByName: { name: 'Product Area: Test' } },
}),
};
expect(
await org.getKeyValueFromProjectField('issueNodeId', 'fieldName')
).toEqual('Product Area: Test');
});

it('getIssueDueDateFromProject should return timestamp from project', async function () {
org.api = {
graphql: jest.fn().mockReturnValue({
node: {
fieldValues: {
nodes: [
{},
{},
{
text: '2023-06-23T18:00:00.000Z',
field: { id: org.project.response_due_date_field_id },
},
],
},
},
}),
};
expect(await org.getIssueDueDateFromProject('issueNodeId')).toEqual(
'2023-06-23T18:00:00.000Z'
);
});

it('getIssueDetailsFromNodeId should return issue details', async function () {
org.api = {
graphql: jest.fn().mockReturnValue({
node: { number: 1, repository: { name: 'test-repo' } },
}),
};
expect(await org.getIssueDetailsFromNodeId('issueNodeId')).toEqual({
number: 1,
repo: 'test-repo',
});
});
});
Loading

0 comments on commit a1f6699

Please sign in to comment.