This repository was archived by the owner on Aug 7, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathoctokit.test.js
More file actions
64 lines (55 loc) · 2.24 KB
/
Copy pathoctokit.test.js
File metadata and controls
64 lines (55 loc) · 2.24 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
/**
* Unit tests for the Octokit client module.
*/
import {jest} from '@jest/globals'
// Reset singleton between tests by clearing module cache
beforeEach(() => {
jest.resetModules()
})
describe('octokit', () => {
beforeEach(() => {})
afterEach(() => {})
/**
* Test that Octokit client is created with correct token and options.
*/
test('should create Octokit client with valid token and default api.github.com', async () => {
const {default: getOctokit, getBaseUrl} = await import('../../src/github/octokit.js')
const client = getOctokit('token')
expect(getBaseUrl(client)).toBe('https://api.github.com')
})
/**
* Test constructor options
*/
describe('constructor options', () => {
test('should normalize classic GHE hostname to /api/v3', async () => {
const {default: getOctokit, getBaseUrl} = await import('../../src/github/octokit.js')
const client = getOctokit('token', 'ghe.internal.example.com')
expect(getBaseUrl(client)).toBe('https://ghe.internal.example.com/api/v3')
})
test('should transform GHEC+DR hostname *.ghe.com to api.<host>', async () => {
const {default: getOctokit, getBaseUrl} = await import('../../src/github/octokit.js')
const client = getOctokit('token', 'region1.ghe.com')
expect(getBaseUrl(client)).toBe('https://api.region1.ghe.com')
})
test('should preserve already api-prefixed GHEC+DR hostname without /api/v3', async () => {
const {default: getOctokit, getBaseUrl} = await import('../../src/github/octokit.js')
const client = getOctokit('token', 'api.region1.ghe.com')
expect(getBaseUrl(client)).toBe('https://api.region1.ghe.com')
})
test('should handle default values', async () => {
const {default: getOctokit, getBaseUrl} = await import('../../src/github/octokit.js')
const client = getOctokit('token')
expect(getBaseUrl(client)).toBe('https://api.github.com')
})
})
/**
* Test client operations
*/
describe('client operations', () => {
test('should perform API requests correctly', async () => {
const {default: getOctokit} = await import('../../src/github/octokit.js')
const client = getOctokit('token')
expect(typeof client.request).toBe('function')
})
})
})