Skip to content

Commit 081501e

Browse files
authored
Add tests for getRepoPath (#6)
1 parent 0c36c4c commit 081501e

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,48 @@ test('is500', t => {
9595
document.title = 'Server Error · Issue #266 · sintaxi/surge · GitHub';
9696
t.false(pageDetect.is500());
9797
});
98+
99+
test('getRepoPath', t => {
100+
const pairs = new Map<string, string | undefined>([
101+
[
102+
'https://github.com',
103+
undefined,
104+
],
105+
[
106+
'https://gist.github.com/',
107+
undefined,
108+
],
109+
[
110+
'https://github.com/settings/developers',
111+
undefined,
112+
],
113+
[
114+
'https://github.com/sindresorhus/refined-github',
115+
'',
116+
],
117+
[
118+
'https://github.com/sindresorhus/refined-github/',
119+
'',
120+
],
121+
[
122+
'https://github.com/sindresorhus/refined-github/blame/master/package.json',
123+
'blame/master/package.json',
124+
],
125+
[
126+
'https://github.com/sindresorhus/refined-github/commit/57bf4',
127+
'commit/57bf4',
128+
],
129+
[
130+
'https://github.com/sindresorhus/refined-github/compare/test-branch?quick_pull=0',
131+
'compare/test-branch',
132+
],
133+
[
134+
'https://github.com/sindresorhus/refined-github/tree/master/distribution',
135+
'tree/master/distribution',
136+
],
137+
]);
138+
139+
for (const [url, result] of pairs) {
140+
t.is(result, pageDetect.utils.getRepoPath(new URL(url)));
141+
}
142+
});

0 commit comments

Comments
 (0)