aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/utils.test.js
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2021-10-22 22:34:01 +0800
committerGitHub <noreply@github.com>2021-10-22 22:34:01 +0800
commit406bd3780e4dedf3efd8f56f6787d350f5aa3524 (patch)
tree10a5b5c6a60c8117f71731f79a2147bcf801f57e /web_src/js/utils.test.js
parent870f5fbc4146110be37c28e670e57568d3db3288 (diff)
downloadgitea-406bd3780e4dedf3efd8f56f6787d350f5aa3524.tar.gz
gitea-406bd3780e4dedf3efd8f56f6787d350f5aa3524.zip
Fix context popup error (#17398)
* Fix context popup error
Diffstat (limited to 'web_src/js/utils.test.js')
-rw-r--r--web_src/js/utils.test.js20
1 files changed, 19 insertions, 1 deletions
diff --git a/web_src/js/utils.test.js b/web_src/js/utils.test.js
index 859046c87c..3f6f921079 100644
--- a/web_src/js/utils.test.js
+++ b/web_src/js/utils.test.js
@@ -1,5 +1,5 @@
import {
- basename, extname, isObject, uniq, stripTags, joinPaths,
+ basename, extname, isObject, uniq, stripTags, joinPaths, parseIssueHref,
} from './utils.js';
test('basename', () => {
@@ -66,3 +66,21 @@ test('uniq', () => {
test('stripTags', () => {
expect(stripTags('<a>test</a>')).toEqual('test');
});
+
+test('parseIssueHref', () => {
+ expect(parseIssueHref('/owner/repo/issues/1')).toEqual({owner: 'owner', repo: 'repo', type: 'issues', index: '1'});
+ expect(parseIssueHref('/owner/repo/pulls/1?query')).toEqual({owner: 'owner', repo: 'repo', type: 'pulls', index: '1'});
+ expect(parseIssueHref('/owner/repo/issues/1#hash')).toEqual({owner: 'owner', repo: 'repo', type: 'issues', index: '1'});
+ expect(parseIssueHref('/sub/owner/repo/issues/1')).toEqual({owner: 'owner', repo: 'repo', type: 'issues', index: '1'});
+ expect(parseIssueHref('/sub/sub2/owner/repo/pulls/1')).toEqual({owner: 'owner', repo: 'repo', type: 'pulls', index: '1'});
+ expect(parseIssueHref('/sub/sub2/owner/repo/issues/1?query')).toEqual({owner: 'owner', repo: 'repo', type: 'issues', index: '1'});
+ expect(parseIssueHref('/sub/sub2/owner/repo/issues/1#hash')).toEqual({owner: 'owner', repo: 'repo', type: 'issues', index: '1'});
+ expect(parseIssueHref('https://example.com/owner/repo/issues/1')).toEqual({owner: 'owner', repo: 'repo', type: 'issues', index: '1'});
+ expect(parseIssueHref('https://example.com/owner/repo/pulls/1?query')).toEqual({owner: 'owner', repo: 'repo', type: 'pulls', index: '1'});
+ expect(parseIssueHref('https://example.com/owner/repo/issues/1#hash')).toEqual({owner: 'owner', repo: 'repo', type: 'issues', index: '1'});
+ expect(parseIssueHref('https://example.com/sub/owner/repo/issues/1')).toEqual({owner: 'owner', repo: 'repo', type: 'issues', index: '1'});
+ expect(parseIssueHref('https://example.com/sub/sub2/owner/repo/pulls/1')).toEqual({owner: 'owner', repo: 'repo', type: 'pulls', index: '1'});
+ expect(parseIssueHref('https://example.com/sub/sub2/owner/repo/issues/1?query')).toEqual({owner: 'owner', repo: 'repo', type: 'issues', index: '1'});
+ expect(parseIssueHref('https://example.com/sub/sub2/owner/repo/issues/1#hash')).toEqual({owner: 'owner', repo: 'repo', type: 'issues', index: '1'});
+ expect(parseIssueHref('')).toEqual({owner: undefined, repo: undefined, type: undefined, index: undefined});
+});