-
Notifications
You must be signed in to change notification settings - Fork 5
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 #4793 from dfe-analytical-services/ees-5085
EES-5085 Fix incorrect slugs for updated publication titles with dashes and spaces
- Loading branch information
Showing
4 changed files
with
32 additions
and
31 deletions.
There are no files selected for viewing
45 changes: 22 additions & 23 deletions
45
src/GovUk.Education.ExploreEducationStatistics.Content.Model.Tests/NamingUtilTests.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 |
---|---|---|
@@ -1,37 +1,36 @@ | ||
using Xunit; | ||
using static GovUk.Education.ExploreEducationStatistics.Content.Model.NamingUtils; | ||
|
||
namespace GovUk.Education.ExploreEducationStatistics.Content.Model.Tests | ||
namespace GovUk.Education.ExploreEducationStatistics.Content.Model.Tests; | ||
|
||
public abstract class NamingUtilTests | ||
{ | ||
public class NamingUtilTests | ||
public class SlugFromTitleTests | ||
{ | ||
|
||
[Fact] | ||
public void ReleaseSlugFromTitle_CalendarYear() | ||
public void CalendarYearTitle() | ||
{ | ||
var slug = SlugFromTitle("calendar year 2019"); | ||
Assert.Equal("calendar-year-2019", slug); | ||
Assert.Equal("calendar-year-2019", SlugFromTitle("calendar year 2019")); | ||
} | ||
|
||
[Fact] | ||
public void ReleaseSlugFromTitle_NonCalendarYear() | ||
public void NonCalendarYearTitle() | ||
{ | ||
var slug = SlugFromTitle("tax year 2019/20"); | ||
Assert.Equal("tax-year-2019-20", slug); | ||
Assert.Equal("tax-year-2019-20", SlugFromTitle("tax year 2019/20")); | ||
} | ||
|
||
|
||
[Fact] | ||
public void GenerateSlugFromTitle() | ||
|
||
[Theory] | ||
[InlineData("title", "title")] | ||
[InlineData("TITLE", "title")] | ||
[InlineData("A sentence with spaces", "a-sentence-with-spaces")] | ||
[InlineData("A - sentence - with - - dashes - and -- spaces", "a-sentence-with-dashes-and-spaces")] | ||
[InlineData("A sentence with !@£('\\) non alpha numeric characters", "a-sentence-with-non-alpha-numeric-characters")] | ||
[InlineData("A sentence with non alpha numeric characters at the end !@£('\\)", "a-sentence-with-non-alpha-numeric-characters-at-the-end")] | ||
[InlineData("a sentence with big spaces ", "a-sentence-with-big-spaces")] | ||
[InlineData("a sentence with numbers 1 2 3 and 4", "a-sentence-with-numbers-1-2-3-and-4")] | ||
public void EdgeCaseTitles(string title, string expectedSlug) | ||
{ | ||
Assert.Equal("title", SlugFromTitle("title")); | ||
Assert.Equal("title", SlugFromTitle("TITLE")); | ||
Assert.Equal("a-sentence-with-spaces",SlugFromTitle("A sentence with spaces")); | ||
Assert.Equal("a-sentence-with-non-alpha-numeric-characters",SlugFromTitle("A sentence with !@£('\\) non alpha numeric characters")); | ||
Assert.Equal("a-sentence-with-non-alpha-numeric-characters-at-the-end", SlugFromTitle("A sentence with non alpha numeric characters at the end !@£('\\)")); | ||
Assert.Equal("a-sentence-with-big-spaces", SlugFromTitle("a sentence with big spaces ")); | ||
Assert.Equal("a-sentence-with-numbers-1-2-3-and-4", SlugFromTitle("a sentence with numbers 1 2 3 and 4")); | ||
Assert.Equal(expectedSlug, SlugFromTitle(title)); | ||
} | ||
|
||
} | ||
} | ||
} |
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