forked from download-directory/download-directory.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepository-info.test.ts
More file actions
82 lines (81 loc) · 2.74 KB
/
repository-info.test.ts
File metadata and controls
82 lines (81 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import {test, expect} from 'vitest';
import getRepositoryInfo from './repository-info.js';
test('getRepositoryInfo', async () => {
await expect(getRepositoryInfo('https://github.com/user')).resolves.toMatchInlineSnapshot(`
{
"error": "NOT_A_REPOSITORY",
}
`);
await expect(getRepositoryInfo('https://github.com/fregante/doma/blob/develop/readme.md')).resolves.toMatchInlineSnapshot(`
{
"error": "NOT_A_DIRECTORY",
}
`);
await expect(getRepositoryInfo('https://github.com/refined-github/sandbox/tree/durian/folder')).resolves.toMatchInlineSnapshot(`
{
"error": "BRANCH_NOT_FOUND",
}
`);
await expect(getRepositoryInfo('https://github.com/refined-github/private/tree/durian/folder')).resolves.toMatchInlineSnapshot(`
{
"error": "REPOSITORY_NOT_FOUND",
}
`);
// Simple branches are not verified at this point. Should they be?
await expect(getRepositoryInfo('https://github.com/refined-github/sandbox/tree/durian')).resolves.toMatchInlineSnapshot(`
{
"directory": "",
"downloadUrl": "https://api.github.com/repos/refined-github/sandbox/zipball/durian",
"gitReference": "durian",
"isPrivate": false,
"repository": "sandbox",
"user": "refined-github",
}
`);
await expect(getRepositoryInfo('https://github.com/refined-github/sandbox/tree/branch/with/slashes')).resolves.toMatchInlineSnapshot(`
{
"directory": "",
"gitReference": "branch/with/slashes",
"isPrivate": false,
"repository": "sandbox",
"user": "refined-github",
}
`);
await expect(getRepositoryInfo('https://github.com/refined-github/sandbox/tree/default-a/.github/workflows')).resolves.toMatchInlineSnapshot(`
{
"directory": ".github/workflows",
"gitReference": "default-a",
"isPrivate": false,
"repository": "sandbox",
"user": "refined-github",
}
`);
await expect(getRepositoryInfo('https://github.com/microsoft/typescript')).resolves.toMatchInlineSnapshot(`
{
"directory": "",
"downloadUrl": "https://api.github.com/repos/microsoft/typescript/zipball",
"isPrivate": false,
"repository": "typescript",
"user": "microsoft",
}
`);
await expect(getRepositoryInfo('https://github.com/fregante/doma/tree/develop')).resolves.toMatchInlineSnapshot(`
{
"directory": "",
"downloadUrl": "https://api.github.com/repos/fregante/doma/zipball/develop",
"gitReference": "develop",
"isPrivate": false,
"repository": "doma",
"user": "fregante",
}
`);
await expect(getRepositoryInfo('https://github.com/wesbos/JavaScript30/tree/master/01%20-%20JavaScript%20Drum%20Kit/sounds')).resolves.toMatchInlineSnapshot(`
{
"directory": "01 - JavaScript Drum Kit/sounds",
"gitReference": "master",
"isPrivate": false,
"repository": "JavaScript30",
"user": "wesbos",
}
`);
});