import { describe, expect, it } from 'vitest';
import { isPrivateHost } from '../src/core/netHost';

describe('isPrivateHost', () => {
  it('labels LAN / loopback as local', () => {
    for (const h of [
      '192.168.7.76',
      'http://192.168.7.76:1234/v1',
      '10.0.0.5',
      '172.20.1.1',
      'localhost',
      'http://localhost:1234/v1',
      '::1',
      '127.0.0.1',
      'mybox.local',
    ]) {
      expect(isPrivateHost(h), h).toBe(true);
    }
  });

  it('labels public API hosts as cloud', () => {
    for (const h of [
      'api.moonshot.cn',
      'https://api.moonshot.cn/v1',
      'generativelanguage.googleapis.com',
      'https://generativelanguage.googleapis.com/v1beta',
    ]) {
      expect(isPrivateHost(h), h).toBe(false);
    }
  });
});
