Skip to content

Commit

Permalink
Added test to verify fix for AngleSharp#133
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Jun 15, 2023
1 parent 6d52e79 commit 10845f2
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/AngleSharp.Css.Tests/Library/StringRepresentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ namespace AngleSharp.Css.Tests.Library
{
using AngleSharp.Css.Dom;
using AngleSharp.Css.Parser;
using AngleSharp.Css.Tests.Mocks;
using AngleSharp.Css.Values;
using AngleSharp.Dom;
using AngleSharp.Html.Dom;
using AngleSharp.Io;
using NUnit.Framework;
using System.IO;
using System.Threading.Tasks;
using static CssConstructionFunctions;

[TestFixture]
Expand Down Expand Up @@ -151,5 +156,27 @@ public void BorderWithEmptyPx_Issue129()

Assert.AreEqual("border-width: 1px", css);
}

[Test]
public async Task MediaListForLinkedStyleSheet_Issue133()
{
var html = "<link href=\"style.css\" rel=\"stylesheet\">";
var mockRequester = new MockRequester();
mockRequester.BuildResponse(request =>
{
if (request.Address.Path.EndsWith("style.css"))
{
return "div#A { color: blue; }";
}

return null;
});
var config = Configuration.Default.WithCss().WithMockRequester(mockRequester);
var context = BrowsingContext.New(config);
var document = await context.OpenAsync((res) => res.Content(html));
var link = document.QuerySelector<IHtmlLinkElement>("link");
Assert.AreEqual("", link.Sheet.Media.MediaText);
Assert.IsTrue(link.Sheet.Media.Validate(new DefaultRenderDevice()));
}
}
}

0 comments on commit 10845f2

Please sign in to comment.