Skip to content

Commit

Permalink
Validate that #126 can be done
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Jun 16, 2023
1 parent 50d8e9d commit 15cb522
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/AngleSharp.Css.Tests/Library/ExtractInfos.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace AngleSharp.Css.Tests.Library
{
using AngleSharp.Css.Dom;
using AngleSharp.Css.Values;
using AngleSharp.Dom;
using AngleSharp.Html.Dom;
using NUnit.Framework;

[TestFixture]
public class ExtractInfosTests
{
[Test]
public void GetFontUrl_Issue126()
{
var css = @"@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 400;
src: url(https://example.org/some-font.ttf) format('truetype');
}";
var html = $"<style>{css}</style>";
var document = html.ToHtmlDocument(Configuration.Default.WithCss());
var style = document.QuerySelector<IHtmlStyleElement>("style");
var sheet = style.Sheet as ICssStyleSheet;
var fontFace = sheet.Rules[0] as ICssFontFaceRule;
var src = fontFace.GetProperty("src").RawValue;
var url = ((src as ICssMultipleValue)[0] as ICssMultipleValue)[0] as CssUrlValue;
Assert.AreEqual("https://example.org/some-font.ttf", url.Path);
}
}
}

0 comments on commit 15cb522

Please sign in to comment.