-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathgitHubUtils.test.mjs
More file actions
56 lines (49 loc) · 1.68 KB
/
gitHubUtils.test.mjs
File metadata and controls
56 lines (49 loc) · 1.68 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
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
const { getGitHubAvatarUrl, getGitHubBlobUrl, getGitHubApiDocsUrl } =
await import('#site/util/gitHubUtils');
describe('gitHubUtils', () => {
it('getGitHubAvatarUrl returns the correct URL', () => {
assert.equal(
getGitHubAvatarUrl('octocat'),
'https://avatars.githubusercontent.com/octocat'
);
});
it('getGitHubBlobUrl returns the correct URL', () => {
const result = getGitHubBlobUrl('learn/getting-started/introduction.md');
const expected =
'https://github.com/nodejs/nodejs.org/blob/main/apps/site/pages/en/learn/getting-started/introduction.md';
assert.equal(result, expected);
});
it('getGitHubApiDocsUrl returns the correct URL', () => {
const result = getGitHubApiDocsUrl('assert');
const expected =
'https://api.github.com/repos/nodejs/node/contents/doc/api?ref=assert';
assert.equal(result, expected);
});
describe('getGitHubAvatarUrl', () => {
it('should return a valid GitHub avatar URL', () => {
assert.equal(
getGitHubAvatarUrl('octocat'),
'https://avatars.githubusercontent.com/octocat'
);
});
});
describe('getGitHubBlobUrl', () => {
it('should return the correct blob URL', () => {
assert.ok(
getGitHubBlobUrl('testfile.md').includes(
'blob/main/apps/site/pages/en/testfile.md'
)
);
});
});
describe('getGitHubApiDocsUrl', () => {
it('should return the correct API docs URL', () => {
assert.equal(
getGitHubApiDocsUrl('v18.x'),
'https://api.github.com/repos/nodejs/node/contents/doc/api?ref=v18.x'
);
});
});
});