diff --git a/__tests__/utils.test.ts b/__tests__/utils.test.ts index 548f286..cc650e3 100755 --- a/__tests__/utils.test.ts +++ b/__tests__/utils.test.ts @@ -1,5 +1,6 @@ import { HIDDEN_MARKER_END, HIDDEN_MARKER_START, WARNING_MESSAGE_ABOUT_HIDDEN_MARKERS } from '../src/constants'; -import { getJIRAIssueKeyByDefaultRegexp, getJIRAIssueKeysByCustomRegexp, getPRDescription, shouldSkipBranch } from '../src/utils'; +import { JIRADetails } from '../src/types'; +import { getJIRAIssueKeyByDefaultRegexp, getJIRAIssueKeysByCustomRegexp, getPRDescription, shouldSkipBranch, buildPRDescription } from '../src/utils'; jest.spyOn(console, 'log').mockImplementation(); // avoid actual console.log in test output @@ -112,3 +113,27 @@ this is text below the markers`; expect(description).toEqual(oldPRDescription); }); }); + +describe('buildPRDescription()', () => { + it('should return description HTML from the JIRA details', () => { + const details: JIRADetails = { + key: 'ABC-123', + summary: 'Sample summary', + url: 'example.com/ABC-123', + type: { + name: 'story', + icon: 'icon.png', + }, + project: { + name: 'name', + url: 'url', + key: 'key', + }, + }; + + expect(buildPRDescription(details)).toEqual(`
+ story ABC-123 + Sample summary +

`); + }); +}); diff --git a/src/utils.ts b/src/utils.ts index e025a69..f86f9bc 100755 --- a/src/utils.ts +++ b/src/utils.ts @@ -73,12 +73,8 @@ ${HIDDEN_MARKER_END} export const buildPRDescription = (details: JIRADetails) => { const displayKey = details.key.toUpperCase(); - return ` - -
- ${details.type.name}${displayKey} ${details.summary} -
-
- -`; + return `
+ ${details.type.name} ${displayKey} + ${details.summary} +

`; };