Cleaning up tests and useless TruncateByWords functions
This commit is contained in:
@@ -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 <a href='blah'>with a link</a>";
|
||||
|
||||
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, <b>this</b> is some text <a href='blah'>with a link</a>";
|
||||
|
||||
var helper = new UmbracoHelper();
|
||||
|
||||
var result = helper.TruncateByWords(text, 4, true, false).ToString();
|
||||
var result = helper.TruncateByWords(text, 4).ToString();
|
||||
|
||||
Assert.AreEqual("Hello world, <b>this</b> 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 <a href='blah'>with a link</a>";
|
||||
|
||||
var helper = new UmbracoHelper();
|
||||
|
||||
var result = helper.TruncateByWords(text, 7, true, false).ToString();
|
||||
|
||||
Assert.AreEqual("Hello world, this is some text <a href='blah'>with…</a>", result);
|
||||
}
|
||||
[Test]
|
||||
public void Truncate_By_Words_TagsAsContentOn()
|
||||
{
|
||||
var text = "Hello world, this is some text <a href='blah'>with a link</a>";
|
||||
|
||||
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, <b>this</b> is some text <a href='blah'>with a link</a>";
|
||||
|
||||
var helper = new UmbracoHelper();
|
||||
|
||||
var result = helper.TruncateByWords(text, 4, true, true).ToString();
|
||||
|
||||
Assert.AreEqual("Hello world, <b>this</b> is…", result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Truncate_By_Words_Mid_Tag_TagsAsContentOn()
|
||||
{
|
||||
var text = "Hello world, this is some text <a href='blah'>with a link</a>";
|
||||
|
||||
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 <a href='blah'>with…</a>", result);
|
||||
}
|
||||
|
||||
@@ -1466,7 +1466,7 @@ namespace Umbraco.Web
|
||||
/// </summary>
|
||||
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
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
public IHtmlString TruncateByWords(string html, int words, bool addElipsis, bool treatTagsAsContent)
|
||||
{
|
||||
int length =_stringUtilities.WordsToLength(html, words, treatTagsAsContent);
|
||||
|
||||
return Truncate(html, length, addElipsis, treatTagsAsContent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1496,7 +1486,7 @@ namespace Umbraco.Web
|
||||
/// </summary>
|
||||
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
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user