summaryrefslogtreecommitdiff
path: root/test/utils.ts
diff options
context:
space:
mode:
authorGravatar Jeroen van Warmerdam <jeronevw@hotmail.com> 2019-06-04 20:29:24 +0200
committerGravatar Federico Brigante <github@bfred.it> 2019-06-05 02:29:24 +0800
commit0a6b6b4613a5caa2e21d46d11ef686b13d09504c (patch)
tree99f589c0ad78880db32f16da4bfd66d8cb159451 /test/utils.ts
parented0ace7f1f1fa9b49dbc5733a9606e42031b3188 (diff)
downloadrefined-github-0a6b6b4613a5caa2e21d46d11ef686b13d09504c.tar.gz
refined-github-0a6b6b4613a5caa2e21d46d11ef686b13d09504c.tar.zst
refined-github-0a6b6b4613a5caa2e21d46d11ef686b13d09504c.zip
Link to current branch in More's Compare and Commits links (#2102)
Diffstat (limited to 'test/utils.ts')
-rw-r--r--test/utils.ts41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/utils.ts b/test/utils.ts
index ec3fe4c5..ff1a21d5 100644
--- a/test/utils.ts
+++ b/test/utils.ts
@@ -4,6 +4,7 @@ import {
getDiscussionNumber,
getOwnerAndRepo,
getRepoPath,
+ getRef,
parseTag
} from '../source/libs/utils';
@@ -152,6 +153,46 @@ test('getOwnerAndRepo', t => {
});
});
+test('getRef', t => {
+ const refs: {
+ [url: string]: string | undefined;
+ } = {
+ 'https://github.com/sindresorhus/refined-github': undefined,
+ 'https://github.com/sindresorhus/refined-github/': undefined,
+
+ 'https://github.com/sindresorhus/refined-github/tree/master': 'master',
+ 'https://github.com/sindresorhus/refined-github/tree/62007c8b944808d1b46d42d5e22fa65883d1eaec': '62007c8b944808d1b46d42d5e22fa65883d1eaec',
+
+ 'https://github.com/sindresorhus/refined-github/compare': undefined,
+ 'https://github.com/sindresorhus/refined-github/compare/master': undefined,
+ 'https://github.com/sindresorhus/refined-github/compare/62007c8b944808d1b46d42d5e22fa65883d1eaec': undefined,
+ 'https://github.com/sindresorhus/refined-github/compare/master...test': undefined,
+
+ 'https://github.com/sindresorhus/refined-github/commits': undefined,
+ 'https://github.com/sindresorhus/refined-github/commits/master': 'master',
+ 'https://github.com/sindresorhus/refined-github/commits/62007c8b944808d1b46d42d5e22fa65883d1eaec': '62007c8b944808d1b46d42d5e22fa65883d1eaec',
+
+ 'https://github.com/sindresorhus/refined-github/releases/tag/v1.2.3': undefined,
+
+ 'https://github.com/sindresorhus/refined-github/blob/master/readme.md': 'master',
+ 'https://github.com/sindresorhus/refined-github/blob/62007c8b944808d1b46d42d5e22fa65883d1eaec/readme.md': '62007c8b944808d1b46d42d5e22fa65883d1eaec',
+
+ 'https://github.com/sindresorhus/refined-github/wiki/topic': undefined,
+
+ 'https://github.com/sindresorhus/refined-github/blame/master/readme.md': 'master',
+ 'https://github.com/sindresorhus/refined-github/blame/62007c8b944808d1b46d42d5e22fa65883d1eaec/readme.md': '62007c8b944808d1b46d42d5e22fa65883d1eaec',
+
+ 'https://github.com/sindresorhus/refined-github/pull/123': undefined,
+ 'https://github.com/sindresorhus/refined-github/pull/2105/commits/': undefined,
+ 'https://github.com/sindresorhus/refined-github/pull/2105/commits/9df50080dfddee5f7a2a6a1dc4465166339fedfe': undefined
+ };
+
+ Object.keys(refs).forEach(url => {
+ location.href = url;
+ t.is(refs[url], getRef(), url);
+ });
+});
+
test('parseTag', t => {
t.deepEqual(parseTag(''), {namespace: '', version: ''});
t.deepEqual(parseTag('1.2.3'), {namespace: '', version: '1.2.3'});