From 8b6500730030cf05ee4ff5e3a8e302a1a879bf3e Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Mon, 8 Jan 2024 14:03:41 +0100 Subject: [PATCH] Add Id to anchor and add test (#1278) --- src/Core/Components/Anchor/FluentAnchor.razor | 1 + ...uentAnchor_IdAttribute.verified.razor.html | 4 +++ tests/Core/Anchor/FluentAnchorTests.cs | 34 +++++++++---------- tests/Core/Anchor/FluentAnchorTests.razor | 17 ++++++++++ 4 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 tests/Core/Anchor/FluentAnchorTests.FluentAnchor_IdAttribute.verified.razor.html create mode 100644 tests/Core/Anchor/FluentAnchorTests.razor diff --git a/src/Core/Components/Anchor/FluentAnchor.razor b/src/Core/Components/Anchor/FluentAnchor.razor index fb6de2af50..1137eb8c05 100644 --- a/src/Core/Components/Anchor/FluentAnchor.razor +++ b/src/Core/Components/Anchor/FluentAnchor.razor @@ -1,6 +1,7 @@ @namespace Microsoft.FluentUI.AspNetCore.Components @inherits FluentComponentBase + My Anchor + \ No newline at end of file diff --git a/tests/Core/Anchor/FluentAnchorTests.cs b/tests/Core/Anchor/FluentAnchorTests.cs index 3864631876..d12f818730 100644 --- a/tests/Core/Anchor/FluentAnchorTests.cs +++ b/tests/Core/Anchor/FluentAnchorTests.cs @@ -4,20 +4,20 @@ namespace Microsoft.FluentUI.AspNetCore.Components.Tests.Anchor; -public class FluentAnchorTests : TestBase +public partial class FluentAnchorTests : TestContext { private const string FluentAnchorRazorJs = "./_content/Microsoft.FluentUI.AspNetCore.Components/Components/Anchor/FluentAnchor.razor.js"; public FluentAnchorTests() { - TestContext.JSInterop.SetupModule(FluentAnchorRazorJs); + JSInterop.SetupModule(FluentAnchorRazorJs); } [Fact] public void FluentAnchor_AttributesDefaultValues() { // Arrange - var cut = TestContext.RenderComponent(parameters => + var cut = RenderComponent(parameters => { parameters.AddChildContent("click me!"); }); @@ -32,7 +32,7 @@ public void FluentAnchor_AttributesDefaultValues() public void FluentAnchor_DownloadAttribute(string download) { // Arrange && Act - var cut = TestContext.RenderComponent(parameters => + var cut = RenderComponent(parameters => { parameters.Add(p => p.Href, "https://fast.design"); parameters.Add(p => p.Download, download); @@ -50,7 +50,7 @@ public void FluentAnchor_DownloadAttribute(string download) public void FluentAnchor_HrefAttribute(string url, string suffix) { // Arrange && Act - var cut = TestContext.RenderComponent(parameters => + var cut = RenderComponent(parameters => { parameters.Add(p => p.Href, url); parameters.AddChildContent("click me!"); @@ -66,7 +66,7 @@ public void FluentAnchor_HrefAttribute(string url, string suffix) public void FluentAnchor_HrefLangAttribute(string lang) { // Arrange - var cut = TestContext.RenderComponent( + var cut = RenderComponent( parameters => parameters .Add(p => p.Hreflang, lang) .Add(p => p.Href, "https://fast.design") @@ -82,7 +82,7 @@ public void FluentAnchor_HrefLangAttribute(string lang) public void FluentAnchor_PingAttribute(string ping, string suffix) { // Arrange - var cut = TestContext.RenderComponent( + var cut = RenderComponent( parameters => parameters .Add(p => p.Ping, ping) .Add(p => p.Href, "https://fast.design") @@ -98,7 +98,7 @@ public void FluentAnchor_PingAttribute(string ping, string suffix) public void FluentAnchor_ReferrerPolicyAttribute(string referrerPolicy) { // Arrange - var cut = TestContext.RenderComponent( + var cut = RenderComponent( parameters => parameters .Add(p => p.Referrerpolicy, referrerPolicy) .Add(p => p.Href, "https://fast.design") @@ -114,7 +114,7 @@ public void FluentAnchor_ReferrerPolicyAttribute(string referrerPolicy) public void FluentAnchor_RelAttribute(string rel) { // Arrange - var cut = TestContext.RenderComponent( + var cut = RenderComponent( parameters => parameters .Add(p => p.Rel, rel) .Add(p => p.Href, "https://fast.design") @@ -136,7 +136,7 @@ public void FluentAnchor_TargetAttribute(string target) IRenderedComponent? cut = null; Action action = () => { - cut = TestContext.RenderComponent( + cut = RenderComponent( parameters => parameters .Add(p => p.Target, target) .Add(p => p.Href, "https://fast.design") @@ -161,7 +161,7 @@ public void FluentAnchor_TargetAttribute(string target) public void FluentAnchor_TypeAttribute(string type, string suffix) { // Arrange - var cut = TestContext.RenderComponent( + var cut = RenderComponent( parameters => parameters .Add(p => p.Type, type) .Add(p => p.Href, "https://fast.design") @@ -182,7 +182,7 @@ public void FluentAnchor_TypeAttribute(string type, string suffix) public void FluentAnchor_AppearanceAttribute(Appearance appearance) { // Arrange - var cut = TestContext.RenderComponent( + var cut = RenderComponent( parameters => parameters .Add(p => p.Appearance, appearance) .Add(p => p.Href, "https://fast.design") @@ -196,7 +196,7 @@ public void FluentAnchor_AppearanceAttribute(Appearance appearance) public void FluentAnchor_Without_ChildContent() { // Arrange - var cut = TestContext.RenderComponent(); + var cut = RenderComponent(); // Assert cut.Verify(); @@ -206,7 +206,7 @@ public void FluentAnchor_Without_ChildContent() public void FluentAnchor_WithAdditionalCSSClass() { // Arrange & Act - var cut = TestContext.RenderComponent( + var cut = RenderComponent( parameters => parameters .Add(p => p.Href, "https://fast.design") .Add(p => p.Class, "additional-class") @@ -220,7 +220,7 @@ public void FluentAnchor_WithAdditionalCSSClass() public void FluentAnchor_WithAdditionalStyle() { // Arrange & Act - var cut = TestContext.RenderComponent( + var cut = RenderComponent( parameters => parameters .Add(p => p.Href, "https://fast.design") .Add(p => p.Style, "background-color: black;") @@ -234,7 +234,7 @@ public void FluentAnchor_WithAdditionalStyle() public void FluentAnchor_WithASingleAdditionalAttribute() { // Arrange & Act - var cut = TestContext.RenderComponent( + var cut = RenderComponent( parameters => parameters .Add(p => p.Href, "https://fast.design") .AddUnmatched("additional", "additional-value") @@ -248,7 +248,7 @@ public void FluentAnchor_WithASingleAdditionalAttribute() public void FluentAnchor_WithMultipleAdditionalAttributes() { // Arrange & Act - var cut = TestContext.RenderComponent( + var cut = RenderComponent( parameters => parameters .Add(p => p.Href, "https://fast.design") .AddUnmatched("additional1", "additional1-value") diff --git a/tests/Core/Anchor/FluentAnchorTests.razor b/tests/Core/Anchor/FluentAnchorTests.razor new file mode 100644 index 0000000000..6a46bd5870 --- /dev/null +++ b/tests/Core/Anchor/FluentAnchorTests.razor @@ -0,0 +1,17 @@ +@using Xunit +@inherits TestContext + +@code +{ + [Fact] + public void FluentAnchor_IdAttribute() + { + // Arrange + // Act + var cut = Render(@ + My Anchor + ); + // Assert + cut.Verify(); + } +} \ No newline at end of file