83 lines
3.5 KiB
TypeScript
83 lines
3.5 KiB
TypeScript
import { parsePath } from '../utils';
|
|
import { ENTITY_TYPE } from '../types';
|
|
|
|
test('parsePath gitlab issue', () => {
|
|
const path = parsePath('https://git.sakamoto.pl/laudompat/haruhi-dl/-/issues/33#note_169');
|
|
expect(path.domain).toEqual('git.sakamoto.pl');
|
|
expect(path.path).toEqual('laudompat/haruhi-dl');
|
|
expect(path.entity).toEqual(ENTITY_TYPE.ISSUE);
|
|
expect(path.entityID).toEqual('33');
|
|
});
|
|
test('parsePath github issue', () => {
|
|
const path = parsePath('https://github.com/haruhi-dl/haruhi-dl/issues/1#issue-802641781');
|
|
expect(path.domain).toEqual('github.com');
|
|
expect(path.path).toEqual('haruhi-dl/haruhi-dl');
|
|
expect(path.entity).toEqual(ENTITY_TYPE.ISSUE);
|
|
expect(path.entityID).toEqual('1');
|
|
});
|
|
|
|
test('parsePath gitlab merge request', () => {
|
|
const path = parsePath(
|
|
'https://gitlab.com/gitlab-org/5-minute-production-app/examples/expressjs-app/-/merge_requests/1',
|
|
);
|
|
expect(path.domain).toEqual('gitlab.com');
|
|
expect(path.path).toEqual('gitlab-org/5-minute-production-app/examples/expressjs-app');
|
|
expect(path.entity).toEqual(ENTITY_TYPE.MERGE_REQUEST);
|
|
expect(path.entityID).toEqual('1');
|
|
});
|
|
test('parsePath github merge request', () => {
|
|
const path = parsePath('https://github.com/AliasIO/wappalyzer/pull/3438#issue-509001361');
|
|
expect(path.domain).toEqual('github.com');
|
|
expect(path.path).toEqual('AliasIO/wappalyzer');
|
|
expect(path.entity).toEqual(ENTITY_TYPE.MERGE_REQUEST);
|
|
expect(path.entityID).toEqual('3438');
|
|
});
|
|
|
|
test('parsePath gitlab project', () => {
|
|
const path = parsePath('https://framagit.org/erupcja/uonetplus-hebe-api-docs?fbclid=xD');
|
|
expect(path.domain).toEqual('framagit.org');
|
|
expect(path.path).toEqual('erupcja/uonetplus-hebe-api-docs');
|
|
expect(path.entity).toBeNull();
|
|
expect(path.entityID).toBeNull();
|
|
});
|
|
test('parsePath gitlab project (trailing slash)', () => {
|
|
const path = parsePath('https://framagit.org/erupcja/uonetplus-hebe-api-docs/');
|
|
expect(path.domain).toEqual('framagit.org');
|
|
expect(path.path).toEqual('erupcja/uonetplus-hebe-api-docs');
|
|
expect(path.entity).toBeNull();
|
|
expect(path.entityID).toBeNull();
|
|
});
|
|
test('parsePath github project', () => {
|
|
const path = parsePath('https://github.com/haruhi-dl/haruhi-dl#readme');
|
|
expect(path.domain).toEqual('github.com');
|
|
expect(path.path).toEqual('haruhi-dl/haruhi-dl');
|
|
expect(path.entity).toBeNull();
|
|
expect(path.entityID).toBeNull();
|
|
});
|
|
test('parsePath github project (trailing slash)', () => {
|
|
const path = parsePath('https://github.com/haruhi-dl/haruhi-dl/#readme');
|
|
expect(path.domain).toEqual('github.com');
|
|
expect(path.path).toEqual('haruhi-dl/haruhi-dl');
|
|
expect(path.entity).toBeNull();
|
|
expect(path.entityID).toBeNull();
|
|
});
|
|
|
|
test('parsePath gitlab commit', () => {
|
|
const path = parsePath(
|
|
'https://git.sakamoto.pl/laudompat/haruhi-dl/-/commit/1c3ca4fe2c32dc42ceeaec107981287c798d3df0.patch',
|
|
);
|
|
expect(path.domain).toEqual('git.sakamoto.pl');
|
|
expect(path.path).toEqual('laudompat/haruhi-dl');
|
|
expect(path.entity).toEqual(ENTITY_TYPE.COMMIT);
|
|
expect(path.entityID).toEqual('1c3ca4fe2c32dc42ceeaec107981287c798d3df0');
|
|
});
|
|
test('parsePath github commit', () => {
|
|
const path = parsePath(
|
|
'https://github.com/haruhi-dl/haruhi-dl/commit/07f5e2ae1c81d43ecdb5d089ce6bc279560ef25a?diff=split',
|
|
);
|
|
expect(path.domain).toEqual('github.com');
|
|
expect(path.path).toEqual('haruhi-dl/haruhi-dl');
|
|
expect(path.entity).toEqual(ENTITY_TYPE.COMMIT);
|
|
expect(path.entityID).toEqual('07f5e2ae1c81d43ecdb5d089ce6bc279560ef25a');
|
|
});
|