import { describe, expect, test } from 'bun:test' import { extractSubdomain } from './proxy' describe('extractSubdomain', () => { describe('*.localhost (dev)', () => { test('should extract subdomain from clock.localhost:3000', () => { expect(extractSubdomain('clock.localhost:3000')).toBe('clock') }) test('should extract subdomain from clock.localhost', () => { expect(extractSubdomain('clock.localhost')).toBe('clock') }) test('should return null for bare localhost:3000', () => { expect(extractSubdomain('localhost:3000')).toBeNull() }) test('should return null for bare localhost', () => { expect(extractSubdomain('localhost')).toBeNull() }) test('should handle hyphenated app names', () => { expect(extractSubdomain('my-app.localhost:3000')).toBe('my-app') }) }) describe('*.toes.local (production)', () => { test('should extract subdomain from clock.toes.local', () => { expect(extractSubdomain('clock.toes.local')).toBe('clock') }) test('should return null for bare toes.local', () => { expect(extractSubdomain('toes.local')).toBeNull() }) test('should handle hyphenated app names', () => { expect(extractSubdomain('my-app.toes.local')).toBe('my-app') }) }) describe('other hosts', () => { test('should return null for plain IP', () => { expect(extractSubdomain('192.168.1.50:3000')).toBeNull() }) test('should return null for empty string', () => { expect(extractSubdomain('')).toBeNull() }) }) })