-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #958 from DFE-Digital/feat/244053/NonBreakingHyphen
Replace standard Hyphens with non breaking hyphens
- Loading branch information
Showing
4 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
@using Dfe.PlanTech | ||
@model Dfe.PlanTech.Domain.Content.Models.Title; | ||
|
||
<h1 class="govuk-heading-xl">@System.Net.WebUtility.HtmlDecode(Model.Text)</h1> | ||
<h1 class="govuk-heading-xl">@StringExtensions.UseNonBreakingHyphenAndHtmlDecode(Model.Text)</h1> |
22 changes: 22 additions & 0 deletions
22
tests/Dfe.PlanTech.Web.UnitTests/Helpers/StringExtensionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Xunit; | ||
|
||
namespace Dfe.PlanTech.Web.UnitTests.Helpers | ||
{ | ||
public class StringExtensionsTests | ||
{ | ||
// Just to be clear, the expectedText Hyphens are Non breaking Hyphens and inputText Hyphens are standard | ||
[Theory] | ||
[InlineData("Single test-", "Single test‑")] | ||
[InlineData("Single-test", "Single‑test")] | ||
[InlineData("This is -a-test-", "This is ‑a‑test‑")] | ||
[InlineData("This is-a-test", "This is‑a‑test")] | ||
[InlineData(null, null)] | ||
[InlineData("", "")] | ||
public void CheckHyphensConvertedCorrectly(string? inputText, string? expectedText) | ||
{ | ||
var result = StringExtensions.UseNonBreakingHyphenAndHtmlDecode(inputText); | ||
|
||
Assert.Equal(expectedText, result); | ||
} | ||
} | ||
} |