diff --git a/src/Umbraco.Tests/FrontEnd/UmbracoHelperTests.cs b/src/Umbraco.Tests/FrontEnd/UmbracoHelperTests.cs index 1e808ab8b2..f0ba027ca4 100644 --- a/src/Umbraco.Tests/FrontEnd/UmbracoHelperTests.cs +++ b/src/Umbraco.Tests/FrontEnd/UmbracoHelperTests.cs @@ -95,72 +95,37 @@ namespace Umbraco.Tests.FrontEnd } [Test] - public void Truncate_By_Words_TagsAsContentOff() + public void Truncate_By_Words_TagsAsContent() { var text = "Hello world, this is some text with a link"; var helper = new UmbracoHelper(); - var result = helper.TruncateByWords(text, 4, true, false).ToString(); + var result = helper.TruncateByWords(text, 4).ToString(); Assert.AreEqual("Hello world, this is…", result); } [Test] - public void Truncate_By_Words_With_Tag_TagsAsContentOff() + public void Truncate_By_Words_With_Tag_TagsAsContent() { var text = "Hello world, this is some text with a link"; var helper = new UmbracoHelper(); - var result = helper.TruncateByWords(text, 4, true, false).ToString(); + var result = helper.TruncateByWords(text, 4).ToString(); Assert.AreEqual("Hello world, this is…", result); } [Test] - public void Truncate_By_Words_Mid_Tag_TagsAsContentOff() + public void Truncate_By_Words_Mid_Tag_TagsAsContent() { var text = "Hello world, this is some text with a link"; var helper = new UmbracoHelper(); - var result = helper.TruncateByWords(text, 7, true, false).ToString(); - - Assert.AreEqual("Hello world, this is some text with…", result); - } - [Test] - public void Truncate_By_Words_TagsAsContentOn() - { - var text = "Hello world, this is some text with a link"; - - var helper = new UmbracoHelper(); - - var result = helper.TruncateByWords(text, 4, true, true).ToString(); - - Assert.AreEqual("Hello world, this is…", result); - } - - [Test] - public void Truncate_By_Words_With_Tag_TagsAsContentOn() - { - var text = "Hello world, this is some text with a link"; - - var helper = new UmbracoHelper(); - - var result = helper.TruncateByWords(text, 4, true, true).ToString(); - - Assert.AreEqual("Hello world, this is…", result); - } - - [Test] - public void Truncate_By_Words_Mid_Tag_TagsAsContentOn() - { - var text = "Hello world, this is some text with a link"; - - var helper = new UmbracoHelper(); - - var result = helper.TruncateByWords(text, 7, true, true).ToString(); + var result = helper.TruncateByWords(text, 7).ToString(); Assert.AreEqual("Hello world, this is some text with…", result); } diff --git a/src/Umbraco.Web/UmbracoHelper.cs b/src/Umbraco.Web/UmbracoHelper.cs index 6969bc3a60..cc8bf2bdf4 100644 --- a/src/Umbraco.Web/UmbracoHelper.cs +++ b/src/Umbraco.Web/UmbracoHelper.cs @@ -1466,7 +1466,7 @@ namespace Umbraco.Web /// public IHtmlString TruncateByWords(string html, int words) { - int length = _stringUtilities.WordsToLength(html, words, false); + int length = _stringUtilities.WordsToLength(html, words); return Truncate(html, length, true, false); } @@ -1476,19 +1476,9 @@ namespace Umbraco.Web /// public IHtmlString TruncateByWords(string html, int words, bool addElipsis) { - int length = _stringUtilities.WordsToLength(html, words, false); + int length = _stringUtilities.WordsToLength(html, words); return Truncate(html, length, addElipsis, false); - } - - /// - /// Truncates a string to a given amount of words, can add a elipsis at the end (...). Method checks for open html tags, and makes sure to close them - /// - public IHtmlString TruncateByWords(string html, int words, bool addElipsis, bool treatTagsAsContent) - { - int length =_stringUtilities.WordsToLength(html, words, treatTagsAsContent); - - return Truncate(html, length, addElipsis, treatTagsAsContent); } /// @@ -1496,7 +1486,7 @@ namespace Umbraco.Web /// public IHtmlString TruncateByWords(IHtmlString html, int words) { - int length = _stringUtilities.WordsToLength(html.ToHtmlString(), words, false); + int length = _stringUtilities.WordsToLength(html.ToHtmlString(), words); return Truncate(html, length, true, false); } @@ -1506,19 +1496,9 @@ namespace Umbraco.Web /// public IHtmlString TruncateByWords(IHtmlString html, int words, bool addElipsis) { - int length = _stringUtilities.WordsToLength(html.ToHtmlString(), words, false); + int length = _stringUtilities.WordsToLength(html.ToHtmlString(), words); return Truncate(html, length, addElipsis, false); - } - - /// - /// Truncates a string to a given amount of words, can add a elipsis at the end (...). Method checks for open html tags, and makes sure to close them - /// - public IHtmlString TruncateByWords(IHtmlString html, int words, bool addElipsis, bool treatTagsAsContent) - { - int length = _stringUtilities.WordsToLength(html.ToHtmlString(), words, treatTagsAsContent); - - return Truncate(html, length, addElipsis, treatTagsAsContent); } #endregion #endregion