import { isLocalDevPluginSourceUrl, isSecurePluginRemoteUrl } from './plugin-source-url.rules';

describe('plugin source URL rules', () => {
  it('treats localhost HTTP URLs as local dev plugin sources', () => {
    expect(isLocalDevPluginSourceUrl('http://localhost:4200/plugins/e2e-plugin-source.json')).toBe(true);
    expect(isLocalDevPluginSourceUrl('http://127.0.0.1:4200/plugins/e2e-plugin-source.json')).toBe(true);
    expect(isLocalDevPluginSourceUrl('http://example.com/plugins.json')).toBe(false);
    expect(isLocalDevPluginSourceUrl('https://localhost/plugins.json')).toBe(false);
  });

  it('accepts HTTPS and localhost HTTP as secure remote plugin URLs', () => {
    expect(isSecurePluginRemoteUrl('https://plugins.example.test/index.json')).toBe(true);
    expect(isSecurePluginRemoteUrl('http://localhost:4200/plugins/e2e-plugin-source.json')).toBe(true);
    expect(isSecurePluginRemoteUrl('http://example.com/plugins.json')).toBe(false);
  });
});
