Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ All notable changes to **bUnit** will be documented in this file. The project ad
### Fixed

- Do not set the `Uri` or `BaseUri` property on the `FakeNavigationManager` if navigation is prevented by a handler on `net7.0` or greater. Reported and fixed by [@ayyron-dev](https://github.com/ayyron-dev) in [#1647](https://github.com/bUnit-dev/bUnit/issues/1647)
- Use default renderer properties for AngleSharp. Reported by [@jtleaming](https://github.com/jtleaming) in [#1692].

## [1.38.5] - 2025-01-12

Expand Down
12 changes: 10 additions & 2 deletions src/bunit.web/Rendering/BunitHtmlParser.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections;
using System.Diagnostics;
using AngleSharp;
using AngleSharp.Css;
using AngleSharp.Dom;
using AngleSharp.Html.Parser;
using Bunit.Diffing;
Expand Down Expand Up @@ -28,7 +29,8 @@ public sealed class BunitHtmlParser : IDisposable
/// with a AngleSharp context without a <see cref="TestRenderer"/> registered.
/// </summary>
public BunitHtmlParser()
: this(Configuration.Default.WithCss().With(new HtmlComparer())) { }
: this(Configuration.Default.WithCss()
.With(new HtmlComparer())) { }

/// <summary>
/// Initializes a new instance of the <see cref="BunitHtmlParser"/> class
Expand All @@ -43,7 +45,13 @@ public BunitHtmlParser(HtmlComparer htmlComparer, TestContextBase testContext)

private BunitHtmlParser(IConfiguration angleSharpConfiguration)
{
var config = angleSharpConfiguration.With(this);
var config = angleSharpConfiguration
.With(this)
.WithRenderDevice(new DefaultRenderDevice
{
ViewPortWidth = 1920,
ViewPortHeight = 1080,
});
context = BrowsingContext.New(config);
var parseOptions = new HtmlParserOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<div class="my-component" style="width: 5%">
</div>
13 changes: 13 additions & 0 deletions tests/bunit.web.tests/Rendering/RenderedComponentTest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using AngleSharp;
using AngleSharp.Css;
using AngleSharp.Dom;
using Bunit.Rendering;

namespace Bunit;
Expand Down Expand Up @@ -67,4 +70,14 @@ public void Test021()
cut.Instance.JSRuntime.ShouldNotBeNull();
}
#endif

[Fact(DisplayName = "Using relative units in style attribute can be retrieved")]
public void Test022()
{
var cut = RenderComponent<ComponentWithRelativeUnitAsWidth>();

var text = cut.Find(".my-component").GetInnerText();

text.ShouldNotBeNull();
}
}
Loading