@aaronshaf/ger
Version:
Gerrit CLI and SDK - A modern CLI tool and TypeScript SDK for Gerrit Code Review, built with Effect-TS
64 lines (54 loc) • 2.05 kB
text/typescript
import { describe, test, expect } from 'bun:test'
import { normalizeGerritHost } from '@/utils/url-parser'
describe('Setup Command', () => {
describe('URL normalization integration', () => {
test('should normalize host URL using normalizeGerritHost', () => {
// Test that the utility function is working as expected
expect(normalizeGerritHost('gerrit.example.com')).toBe('https://gerrit.example.com')
expect(normalizeGerritHost('https://gerrit.example.com/')).toBe('https://gerrit.example.com')
expect(normalizeGerritHost('gerrit.example.com:8080')).toBe('https://gerrit.example.com:8080')
})
})
describe('Configuration validation', () => {
test('should validate required fields', () => {
const config = {
host: 'https://gerrit.example.com',
username: 'testuser',
password: 'testpass',
}
expect(config.host).toBeTruthy()
expect(config.username).toBeTruthy()
expect(config.password).toBeTruthy()
})
test('should reject empty required fields', () => {
const config = {
host: '',
username: 'testuser',
password: 'testpass',
}
expect(config.host).toBeFalsy()
})
})
describe('AI tool detection', () => {
test('should check for available tools', () => {
const availableTools = ['claude', 'llm', 'chatgpt']
expect(availableTools).toContain('claude')
})
test('should handle missing tools', () => {
const availableTools: string[] = []
expect(availableTools).not.toContain('nonexistent-tool')
})
})
describe('Connection verification', () => {
test('should test connection success scenario', () => {
const mockResponse = { ok: true, status: 200 }
expect(mockResponse.ok).toBe(true)
expect(mockResponse.status).toBe(200)
})
test('should handle connection failures', () => {
const mockResponse = { ok: false, status: 401 }
expect(mockResponse.ok).toBe(false)
expect(mockResponse.status).toBe(401)
})
})
})