using StellaOps.Feedser.Source.Common.Url;

namespace StellaOps.Feedser.Source.Common.Tests;

public sealed class UrlNormalizerTests
{
    [Fact]
    public void TryNormalize_ResolvesRelative()
    {
        var success = UrlNormalizer.TryNormalize("/foo/bar", new Uri("https://example.test/base/"), out var normalized);

        Assert.True(success);
        Assert.Equal("https://example.test/foo/bar", normalized!.ToString());
    }

    [Fact]
    public void TryNormalize_StripsFragment()
    {
        var success = UrlNormalizer.TryNormalize("https://example.test/path#section", null, out var normalized);

        Assert.True(success);
        Assert.Equal("https://example.test/path", normalized!.ToString());
    }
}
