|
1 | | -const { generateValidProfileLink } = require('../../lib/modules/helpers'); |
| 1 | +const { |
| 2 | + generatePrTitle, |
| 3 | + generateValidProfileLink, |
| 4 | +} = require('../../lib/modules/helpers'); |
| 5 | + |
| 6 | +describe('generatePrTitle', () => { |
| 7 | + const message = 'add tenshiAMD as a contributor'; |
| 8 | + |
| 9 | + test('returns valid message - with 1 contribution type/s', async () => { |
| 10 | + let contributions = ['code']; |
| 11 | + let validText = generatePrTitle(message, contributions); |
| 12 | + |
| 13 | + expect(validText).toEqual('add tenshiAMD as a contributor for code'); |
| 14 | + }); |
| 15 | + |
| 16 | + test('returns valid message - with 2 contribution type/s', async () => { |
| 17 | + let contributions = ['code', 'bug']; |
| 18 | + let validText = generatePrTitle(message, contributions); |
| 19 | + |
| 20 | + expect(validText).toEqual('add tenshiAMD as a contributor for code, and bug'); |
| 21 | + }); |
| 22 | + |
| 23 | + test('returns valid message - with 3 contribution type/s', async () => { |
| 24 | + let contributions = ['code', 'bug', 'design']; |
| 25 | + let validText = generatePrTitle(message, contributions); |
| 26 | + |
| 27 | + expect(validText).toEqual('add tenshiAMD as a contributor for code, bug, and design'); |
| 28 | + }); |
| 29 | + |
| 30 | + test('returns valid message - with nth contribution type/s', async () => { |
| 31 | + let contributions = ['code', 'bug', 'a11y', 'design', 'review']; |
| 32 | + let validText = generatePrTitle(message, contributions); |
| 33 | + |
| 34 | + expect(validText).toEqual(`add tenshiAMD as a contributor for code, bug, and ${contributions.length - 2} more`); |
| 35 | + }); |
| 36 | +}); |
2 | 37 |
|
3 | 38 | describe('generateValidProfileLink', () => { |
4 | 39 | const githubProfileUrl = 'https://github.com/tenshiAMD' |
@@ -28,35 +63,35 @@ describe('generateValidProfileLink', () => { |
28 | 63 | let url = 'tenshhttpiamd.com'; |
29 | 64 | let validUrl = generateValidProfileLink(url, githubProfileUrl); |
30 | 65 |
|
31 | | - expect(validUrl).toEqual(url); |
| 66 | + expect(validUrl).toEqual(`http://${url}`); |
32 | 67 | }); |
33 | 68 |
|
34 | 69 | test('returns valid link - valid URL format with `https` in between', async () => { |
35 | 70 | let url = 'tenshhttpsiamd.com'; |
36 | 71 | let validUrl = generateValidProfileLink(url, githubProfileUrl); |
37 | 72 |
|
38 | | - expect(validUrl).toEqual(url); |
| 73 | + expect(validUrl).toEqual(`http://${url}`); |
39 | 74 | }); |
40 | 75 |
|
41 | 76 | test('returns valid link - no protocol', async () => { |
42 | 77 | let url = 'tenshiamd.com'; |
43 | 78 | let validUrl = generateValidProfileLink(url, githubProfileUrl); |
44 | 79 |
|
45 | | - expect(validUrl).toEqual(url); |
| 80 | + expect(validUrl).toEqual(`http://${url}`); |
46 | 81 | }); |
47 | 82 |
|
48 | 83 | test('returns valid link - no protocol and starting with `http`', async () => { |
49 | 84 | let url = 'httptenshiamd.com'; |
50 | 85 | let validUrl = generateValidProfileLink(url, githubProfileUrl); |
51 | 86 |
|
52 | | - expect(validUrl).toEqual(url); |
| 87 | + expect(validUrl).toEqual(`http://${url}`); |
53 | 88 | }); |
54 | 89 |
|
55 | 90 | test('returns valid link - no protocol and starting with `https`', async () => { |
56 | 91 | let url = 'httpstenshiamd.com'; |
57 | 92 | let validUrl = generateValidProfileLink(url, githubProfileUrl); |
58 | 93 |
|
59 | | - expect(validUrl).toEqual(url); |
| 94 | + expect(validUrl).toEqual(`http://${url}`); |
60 | 95 | }); |
61 | 96 |
|
62 | 97 | test('returns valid link - incomplete URL format', async () => { |
|
0 commit comments