Skip to content

Commit b6387b9

Browse files
Fixed Integration Test for Component and Route property binding (#5)
<!-- Provide a general summary of your changes in the Title above --> <!-- Apply the label "bug" or "enhacement" as applicable. --> ## Description / Motivation <!-- Describe your changes in detail --> <!-- Why is this change required? What problem does it solve? --> <!-- If it fixes an open issue, please link to the issue here. --> The integration test for Component and Route property binding mistakenly had `BeEmpty()` instead of `Be()`. This incorrectly made the integration test pass since the Razor View was invalid. It was using the `asp-for` TagHelper attribute to attempt to render the values. However the Model's properties are of type `string?` which do not have an OOTB TagHelper for the `h3` or `p` tags. With the view fixed this test now properly passes and behaves as expected. ## Testing - [X] The Unit & Intergration tests are passing. - [X] I have added the necesary tests to cover my changes. ## Terms <!-- Place an X in the [] to check. --> <!-- The Code of Conduct helps create a safe space for everyone. We require that everyone agrees to it. --> - [X] I agree to follow this project's [Code of Conduct](CODE_OF_CONDUCT.md). Co-authored-by: Ivan Lieckens <[email protected]>
1 parent 871f753 commit b6387b9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

tests/Sitecore.AspNetCore.SDK.RenderingEngine.Integration.Tests/Fixtures/Binding/ComplexModelBindingFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ public async Task SitecoreLayoutModelBinders_BindDataCorrectly()
7676
.Should().Be(TestConstants.SearchKeywords);
7777

7878
sectionNode.ChildNodes.First(n => n.Id.Equals("componentProperty", StringComparison.OrdinalIgnoreCase)).InnerText
79-
.Should().BeEmpty("Complex-Component");
79+
.Should().Be("Complex-Component");
8080

8181
sectionNode.ChildNodes.First(n => n.Id.Equals("routeProperty", StringComparison.OrdinalIgnoreCase)).InnerText.
82-
Should().BeEmpty("styleguide");
82+
Should().Be("styleguide");
8383

8484
sectionNode.ChildNodes.First(n => n.Id.Equals("fieldContent", StringComparison.OrdinalIgnoreCase)).InnerHtml.
8585
Should().Be(TestConstants.RichTextFieldValue1);

tests/Sitecore.AspNetCore.SDK.RenderingEngine.Integration.Tests/Views/Shared/Components/SitecoreComponent/ComplexComponent.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<section class="complex-component">
44
<h1 id="fieldHeader" asp-for="Header"></h1>
55
<h2 id="routeField" asp-for="PageTitle"></h2>
6-
<h3 id="componentProperty" asp-for="ComponentName"></h3>
7-
<p id="routeProperty" asp-for="RouteName"></p>
6+
<h3 id="componentProperty">@Model.ComponentName</h3>
7+
<p id="routeProperty">@Model.RouteName</p>
88
<p id="routeNestedField" asp-for="RouteFields!.SearchKeywords"></p>
99
<div id="fieldContent" asp-for="Content"></div>
1010
<textarea id="contextProperty" asp-for="IsEditing"></textarea>

0 commit comments

Comments
 (0)