using ErsatzTV.Application.Artworks;
using NUnit.Framework;
using Shouldly;

namespace ErsatzTV.Tests.Application.Artworks;

[TestFixture]
public class ArtworkContentTypeModelTests
{
    [Test]
    public void Sanitized_Should_Keep_An_Allow_Listed_Content_Type()
    {
        var model = new ArtworkContentTypeModel("iptv/logos/abc", "image/png");

        model.Sanitized().ShouldBe(model);
    }

    [TestCase("text/html")]
    [TestCase("application/javascript")]
    [TestCase("image/svg+xml")]
    [TestCase("")]
    public void Sanitized_Should_Blank_A_Non_Allow_Listed_Content_Type(string contentType)
    {
        var model = new ArtworkContentTypeModel("iptv/logos/abc", contentType);

        ArtworkContentTypeModel sanitized = model.Sanitized();

        // Path is preserved; only the untrusted content type is neutralized.
        sanitized.Path.ShouldBe("iptv/logos/abc");
        sanitized.ContentType.ShouldBe(string.Empty);
    }

    [Test]
    public void UrlWithContentType_Should_Be_Just_The_Path()
    {
        // The serve route no longer honors ?contentType= (issue #283), so the URL carries no query.
        new ArtworkContentTypeModel("iptv/logos/abc", "image/png").UrlWithContentType.ShouldBe("iptv/logos/abc");
    }
}
