UNPKG

@aaronshaf/ger

Version:

Gerrit CLI and SDK - A modern CLI tool and TypeScript SDK for Gerrit Code Review, built with Effect-TS

71 lines (58 loc) 2.03 kB
import { describe, test, expect } from 'bun:test' describe('Init Command', () => { describe('token obscuring', () => { test('should obscure short tokens', () => { const obscureToken = (token: string): string => { if (token.length <= 8) return '****' return `${token.substring(0, 4)}****${token.substring(token.length - 4)}` } expect(obscureToken('1234')).toBe('****') }) test('should obscure long tokens', () => { const obscureToken = (token: string): string => { if (token.length <= 8) return '****' return `${token.substring(0, 4)}****${token.substring(token.length - 4)}` } expect(obscureToken('verylongpassword123456')).toBe('very****3456') }) }) describe('URL normalization', () => { test('should remove trailing slashes', () => { const url = 'https://gerrit.example.com/' const normalized = url.replace(/\/$/, '') expect(normalized).toBe('https://gerrit.example.com') }) }) describe('input validation', () => { test('should require non-empty host', () => { const host = '' expect(host).toBeFalsy() }) test('should require non-empty username', () => { const username = '' expect(username).toBeFalsy() }) test('should require non-empty password', () => { const password = '' expect(password).toBeFalsy() }) }) describe('control characters', () => { test('should handle Ctrl+C', () => { const charCode = '\x03'.charCodeAt(0) // Ctrl+C expect(charCode).toBe(3) }) test('should handle Enter key', () => { const charCode = '\r'.charCodeAt(0) // Enter expect(charCode).toBe(13) }) test('should handle backspace', () => { const charCode = '\x7f'.charCodeAt(0) // Backspace expect(charCode).toBe(127) }) test('should filter printable characters', () => { const charCode = 'a'.charCodeAt(0) expect(charCode >= 32 && charCode <= 126).toBe(true) }) }) })