|
1 |
| -import jiraIssue from './' |
| 1 | +import jiraIssue from "./"; |
2 | 2 |
|
3 |
| -declare const global: any |
| 3 | +declare const global: any; |
4 | 4 |
|
5 |
| -describe('jiraIssue()', () => { |
| 5 | +describe("jiraIssue()", () => { |
6 | 6 | beforeEach(() => {
|
7 |
| - global.warn = jest.fn() |
8 |
| - global.message = jest.fn() |
9 |
| - }) |
| 7 | + global.warn = jest.fn(); |
| 8 | + global.message = jest.fn(); |
| 9 | + }); |
10 | 10 | afterEach(() => {
|
11 |
| - global.danger = undefined |
12 |
| - global.warn = undefined |
13 |
| - global.message = undefined |
14 |
| - }) |
15 |
| - it('throws when supplied invalid configuration', () => { |
16 |
| - const anyJira = jiraIssue as any |
17 |
| - expect(() => anyJira()).toThrow() |
18 |
| - expect(() => jiraIssue({} as any)).toThrow() |
19 |
| - expect(() => jiraIssue({ key: 'ABC' } as any)).toThrow() |
20 |
| - expect(() => jiraIssue({ url: 'https://jira.net/browse' } as any)).toThrow() |
21 |
| - }) |
22 |
| - it('warns when PR title is missing JIRA issue key', () => { |
23 |
| - global.danger = { github: { pr: { title: 'Change some things' } } } |
| 11 | + global.danger = undefined; |
| 12 | + global.warn = undefined; |
| 13 | + global.message = undefined; |
| 14 | + }); |
| 15 | + it("throws when supplied invalid configuration", () => { |
| 16 | + const anyJira = jiraIssue as any; |
| 17 | + expect(() => anyJira()).toThrow(); |
| 18 | + expect(() => jiraIssue({} as any)).toThrow(); |
| 19 | + expect(() => jiraIssue({ key: "ABC" } as any)).toThrow(); |
| 20 | + expect(() => |
| 21 | + jiraIssue({ url: "https://jira.net/browse" } as any) |
| 22 | + ).toThrow(); |
| 23 | + }); |
| 24 | + it("warns when PR title is missing JIRA issue key", () => { |
| 25 | + global.danger = { github: { pr: { title: "Change some things" } } }; |
24 | 26 | jiraIssue({
|
25 |
| - key: 'ABC', |
26 |
| - url: 'https://jira.net/browse', |
27 |
| - }) |
| 27 | + key: "ABC", |
| 28 | + url: "https://jira.net/browse" |
| 29 | + }); |
28 | 30 | expect(global.warn).toHaveBeenCalledWith(
|
29 |
| - 'Please add the JIRA issue key to the PR title (e.g. ABC-123)' |
30 |
| - ) |
31 |
| - }) |
32 |
| - it('adds the JIRA issue link to the messages table', () => { |
| 31 | + "Please add the JIRA issue key to the PR title (e.g. ABC-123)" |
| 32 | + ); |
| 33 | + }); |
| 34 | + it("adds the JIRA issue link to the messages table", () => { |
33 | 35 | global.danger = {
|
34 |
| - github: { pr: { title: '[ABC-808] Change some things' } }, |
35 |
| - } |
| 36 | + github: { pr: { title: "[ABC-808] Change some things" } } |
| 37 | + }; |
36 | 38 | jiraIssue({
|
37 |
| - key: 'ABC', |
38 |
| - url: 'https://jira.net/browse', |
39 |
| - }) |
| 39 | + key: "ABC", |
| 40 | + url: "https://jira.net/browse" |
| 41 | + }); |
40 | 42 | expect(global.message).toHaveBeenCalledWith(
|
41 | 43 | ':link: <a href="https://jira.net/browse/ABC-808">ABC-808</a>'
|
42 |
| - ) |
43 |
| - }) |
44 |
| - it('properly concatenates URL parts (trailing slash in url)', () => { |
| 44 | + ); |
| 45 | + }); |
| 46 | + it("properly concatenates URL parts (trailing slash in url)", () => { |
45 | 47 | global.danger = {
|
46 |
| - github: { pr: { title: '[ABC-808] Change some things' } }, |
47 |
| - } |
| 48 | + github: { pr: { title: "[ABC-808] Change some things" } } |
| 49 | + }; |
48 | 50 | jiraIssue({
|
49 |
| - key: 'ABC', |
50 |
| - url: 'https://jira.net/browse/', |
51 |
| - }) |
| 51 | + key: "ABC", |
| 52 | + url: "https://jira.net/browse/" |
| 53 | + }); |
52 | 54 | expect(global.message).toHaveBeenCalledWith(
|
53 | 55 | ':link: <a href="https://jira.net/browse/ABC-808">ABC-808</a>'
|
54 |
| - ) |
55 |
| - }) |
56 |
| - it('matches JIRA issue anywhere in title', () => { |
57 |
| - global.danger = { github: { pr: { title: 'My changes - ABC-123' } } } |
| 56 | + ); |
| 57 | + }); |
| 58 | + it("matches JIRA issue anywhere in title", () => { |
| 59 | + global.danger = { github: { pr: { title: "My changes - ABC-123" } } }; |
58 | 60 | jiraIssue({
|
59 |
| - key: 'ABC', |
60 |
| - url: 'https://jira.net/browse', |
61 |
| - }) |
| 61 | + key: "ABC", |
| 62 | + url: "https://jira.net/browse" |
| 63 | + }); |
62 | 64 | expect(global.message).toHaveBeenCalledWith(
|
63 | 65 | ':link: <a href="https://jira.net/browse/ABC-123">ABC-123</a>'
|
64 |
| - ) |
65 |
| - }) |
66 |
| - it('does not match lowercase JIRA key in PR title', () => { |
| 66 | + ); |
| 67 | + }); |
| 68 | + it("does not match lowercase JIRA key in PR title", () => { |
67 | 69 | global.danger = {
|
68 |
| - github: { pr: { title: '[abc-808] Change some things' } }, |
69 |
| - } |
| 70 | + github: { pr: { title: "[abc-808] Change some things" } } |
| 71 | + }; |
70 | 72 | jiraIssue({
|
71 |
| - key: 'ABC', |
72 |
| - url: 'https://jira.net/browse', |
73 |
| - }) |
74 |
| - expect(global.warn).toHaveBeenCalled() |
75 |
| - }) |
76 |
| - it('honors custom emoji configuration', () => { |
77 |
| - global.danger = { github: { pr: { title: '(ABC-123) Change stuff' } } } |
| 73 | + key: "ABC", |
| 74 | + url: "https://jira.net/browse" |
| 75 | + }); |
| 76 | + expect(global.warn).toHaveBeenCalled(); |
| 77 | + }); |
| 78 | + it("honors custom emoji configuration", () => { |
| 79 | + global.danger = { github: { pr: { title: "(ABC-123) Change stuff" } } }; |
78 | 80 | jiraIssue({
|
79 |
| - emoji: ':paperclip:', |
80 |
| - key: 'ABC', |
81 |
| - url: 'https://jira.net/browse', |
82 |
| - }) |
| 81 | + emoji: ":paperclip:", |
| 82 | + key: "ABC", |
| 83 | + url: "https://jira.net/browse" |
| 84 | + }); |
83 | 85 | expect(global.message).toHaveBeenCalledWith(
|
84 | 86 | ':paperclip: <a href="https://jira.net/browse/ABC-123">ABC-123</a>'
|
85 |
| - ) |
86 |
| - }) |
87 |
| - it('supports multiple JIRA keys in PR title', () => { |
| 87 | + ); |
| 88 | + }); |
| 89 | + it("supports multiple JIRA keys in PR title", () => { |
88 | 90 | global.danger = {
|
89 |
| - github: { pr: { title: '[ABC-123][ABC-456] Change some things' } }, |
90 |
| - } |
| 91 | + github: { pr: { title: "[ABC-123][ABC-456] Change some things" } } |
| 92 | + }; |
91 | 93 | jiraIssue({
|
92 |
| - key: 'ABC', |
93 |
| - url: 'https://jira.net/browse', |
94 |
| - }) |
| 94 | + key: "ABC", |
| 95 | + url: "https://jira.net/browse" |
| 96 | + }); |
95 | 97 | expect(global.message).toHaveBeenCalledWith(
|
96 | 98 | ':link: <a href="https://jira.net/browse/ABC-123">ABC-123</a>, <a href="https://jira.net/browse/ABC-456">ABC-456</a>'
|
97 |
| - ) |
98 |
| - }) |
99 |
| - it('supports multiple JIRA boards in PR title', () => { |
| 99 | + ); |
| 100 | + }); |
| 101 | + it("supports multiple JIRA boards in PR title", () => { |
100 | 102 | global.danger = {
|
101 |
| - github: { pr: { title: '[ABC-123][DEF-456] Change some things' } }, |
102 |
| - } |
| 103 | + github: { pr: { title: "[ABC-123][DEF-456] Change some things" } } |
| 104 | + }; |
103 | 105 | jiraIssue({
|
104 |
| - key: ['ABC', 'DEF'], |
105 |
| - url: 'https://jira.net/browse', |
106 |
| - }) |
| 106 | + key: ["ABC", "DEF"], |
| 107 | + url: "https://jira.net/browse" |
| 108 | + }); |
107 | 109 | expect(global.message).toHaveBeenCalledWith(
|
108 | 110 | ':link: <a href="https://jira.net/browse/ABC-123">ABC-123</a>, <a href="https://jira.net/browse/DEF-456">DEF-456</a>'
|
109 |
| - ) |
110 |
| - }) |
111 |
| -}) |
| 111 | + ); |
| 112 | + }); |
| 113 | +}); |
0 commit comments