2020-12-20 08:36:11 +01:00
|
|
|
|
// Copyright (c) Umbraco.
|
|
|
|
|
|
// See LICENSE for more details.
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2018-06-29 19:52:40 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using NUnit.Framework;
|
2021-02-12 11:49:48 +01:00
|
|
|
|
using Umbraco.Cms.Infrastructure.Macros;
|
2021-02-10 14:45:44 +01:00
|
|
|
|
using Umbraco.Cms.Tests.Common.TestHelpers;
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
2021-02-10 14:58:22 +01:00
|
|
|
|
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Web.Common.Macros
|
2018-06-29 19:52:40 +02:00
|
|
|
|
{
|
|
|
|
|
|
[TestFixture]
|
|
|
|
|
|
public class MacroParserTests
|
|
|
|
|
|
{
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Format_RTE_Data_For_Editor_With_No_Macros()
|
|
|
|
|
|
{
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string content = @"<p>hello world</p>";
|
|
|
|
|
|
string result = MacroTagParser.FormatRichTextContentForPersistence(content);
|
2018-06-29 19:52:40 +02:00
|
|
|
|
Assert.AreEqual(@"<p>hello world</p>", content);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Format_RTE_Data_For_Editor_With_Non_AlphaNumeric_Char_In_Alias()
|
|
|
|
|
|
{
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string content = @"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<?UMBRACO_MACRO macroAlias=""My.Map.isCool eh[boy!]"" />
|
|
|
|
|
|
<p>asdfasdf</p>";
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string result = MacroTagParser.FormatRichTextPersistedDataForEditor(content, new Dictionary<string, string>() { { "test1", "value1" }, { "test2", "value2" } });
|
|
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(
|
|
|
|
|
|
@"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<div class=""umb-macro-holder mceNonEditable"" test1=""value1"" test2=""value2"">
|
|
|
|
|
|
<!-- <?UMBRACO_MACRO macroAlias=""My.Map.isCool eh[boy!]"" /> -->
|
|
|
|
|
|
<ins>Macro alias: <strong>My.Map.isCool eh[boy!]</strong></ins></div>
|
2020-12-20 08:36:11 +01:00
|
|
|
|
<p>asdfasdf</p>".Replace(Environment.NewLine, string.Empty),
|
|
|
|
|
|
result.Replace(Environment.NewLine, string.Empty));
|
2018-06-29 19:52:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Format_RTE_Data_For_Editor()
|
|
|
|
|
|
{
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string content = @"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<?UMBRACO_MACRO macroAlias=""Map"" />
|
|
|
|
|
|
<p>asdfasdf</p>";
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string result = MacroTagParser.FormatRichTextPersistedDataForEditor(content, new Dictionary<string, string>() { { "test1", "value1" }, { "test2", "value2" } });
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
2020-12-20 08:36:11 +01:00
|
|
|
|
Assert.AreEqual(
|
|
|
|
|
|
@"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<div class=""umb-macro-holder mceNonEditable"" test1=""value1"" test2=""value2"">
|
|
|
|
|
|
<!-- <?UMBRACO_MACRO macroAlias=""Map"" /> -->
|
|
|
|
|
|
<ins>Macro alias: <strong>Map</strong></ins></div>
|
2020-12-20 08:36:11 +01:00
|
|
|
|
<p>asdfasdf</p>".Replace(Environment.NewLine, string.Empty),
|
|
|
|
|
|
result.Replace(Environment.NewLine, string.Empty));
|
2018-06-29 19:52:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Format_RTE_Data_For_Editor_Closing_Tag()
|
|
|
|
|
|
{
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string content = @"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<?UMBRACO_MACRO macroAlias=""Map"" ></?UMBRACO_MACRO>
|
|
|
|
|
|
<p>asdfasdf</p>";
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string result = MacroTagParser.FormatRichTextPersistedDataForEditor(content, new Dictionary<string, string>() { { "test1", "value1" }, { "test2", "value2" } });
|
|
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(
|
|
|
|
|
|
@"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<div class=""umb-macro-holder mceNonEditable"" test1=""value1"" test2=""value2"">
|
|
|
|
|
|
<!-- <?UMBRACO_MACRO macroAlias=""Map"" /> -->
|
|
|
|
|
|
<ins>Macro alias: <strong>Map</strong></ins></div>
|
2020-12-20 08:36:11 +01:00
|
|
|
|
<p>asdfasdf</p>".Replace(Environment.NewLine, string.Empty),
|
|
|
|
|
|
result.Replace(Environment.NewLine, string.Empty));
|
2018-06-29 19:52:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Format_RTE_Data_For_Editor_With_Params()
|
|
|
|
|
|
{
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string content = @"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<?UMBRACO_MACRO macroAlias=""Map"" test1=""value1"" test2=""value2"" />
|
|
|
|
|
|
<p>asdfasdf</p>";
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string result = MacroTagParser.FormatRichTextPersistedDataForEditor(content, new Dictionary<string, string>() { { "test1", "value1" }, { "test2", "value2" } });
|
|
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(
|
|
|
|
|
|
@"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<div class=""umb-macro-holder mceNonEditable"" test1=""value1"" test2=""value2"">
|
|
|
|
|
|
<!-- <?UMBRACO_MACRO macroAlias=""Map"" test1=""value1"" test2=""value2"" /> -->
|
|
|
|
|
|
<ins>Macro alias: <strong>Map</strong></ins></div>
|
2020-12-20 08:36:11 +01:00
|
|
|
|
<p>asdfasdf</p>".Replace(Environment.NewLine, string.Empty),
|
|
|
|
|
|
result.Replace(Environment.NewLine, string.Empty));
|
2018-06-29 19:52:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Format_RTE_Data_For_Editor_With_Params_When_MacroAlias_Not_First()
|
|
|
|
|
|
{
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string content = @"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<?UMBRACO_MACRO test1=""value1"" test2=""value2"" macroAlias=""Map"" />
|
|
|
|
|
|
<p>asdfasdf</p>";
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string result = MacroTagParser.FormatRichTextPersistedDataForEditor(content, new Dictionary<string, string>() { { "test1", "value1" }, { "test2", "value2" } });
|
|
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(
|
|
|
|
|
|
@"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<div class=""umb-macro-holder mceNonEditable"" test1=""value1"" test2=""value2"">
|
|
|
|
|
|
<!-- <?UMBRACO_MACRO test1=""value1"" test2=""value2"" macroAlias=""Map"" /> -->
|
|
|
|
|
|
<ins>Macro alias: <strong>Map</strong></ins></div>
|
2020-12-20 08:36:11 +01:00
|
|
|
|
<p>asdfasdf</p>".Replace(Environment.NewLine, string.Empty),
|
|
|
|
|
|
result.Replace(Environment.NewLine, string.Empty));
|
2018-06-29 19:52:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Format_RTE_Data_For_Editor_With_Params_When_MacroAlias_Is_First()
|
|
|
|
|
|
{
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string content = @"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<?UMBRACO_MACRO macroAlias=""Map"" test1=""value1"" test2=""value2"" />
|
|
|
|
|
|
<p>asdfasdf</p>";
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string result = MacroTagParser.FormatRichTextPersistedDataForEditor(content, new Dictionary<string, string>() { { "test1", "value1" }, { "test2", "value2" } });
|
|
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(
|
|
|
|
|
|
@"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<div class=""umb-macro-holder mceNonEditable"" test1=""value1"" test2=""value2"">
|
|
|
|
|
|
<!-- <?UMBRACO_MACRO macroAlias=""Map"" test1=""value1"" test2=""value2"" /> -->
|
|
|
|
|
|
<ins>Macro alias: <strong>Map</strong></ins></div>
|
2020-12-20 08:36:11 +01:00
|
|
|
|
<p>asdfasdf</p>".Replace(Environment.NewLine, string.Empty),
|
|
|
|
|
|
result.Replace(Environment.NewLine, string.Empty));
|
2018-06-29 19:52:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Format_RTE_Data_For_Editor_With_Params_When_Multiple_Macros()
|
|
|
|
|
|
{
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string content = @"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<?UMBRACO_MACRO test1=""value1"" test2=""value2"" macroAlias=""Map"" />
|
|
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<?UMBRACO_MACRO test1=""value1"" macroAlias=""Map"" test2=""value2"" />
|
|
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<?UMBRACO_MACRO macroAlias=""Map"" test1=""value1"" test2=""value2"" />
|
|
|
|
|
|
<p>asdfasdf</p>";
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string result = MacroTagParser.FormatRichTextPersistedDataForEditor(content, new Dictionary<string, string>() { { "test1", "value1" }, { "test2", "value2" } });
|
|
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(
|
|
|
|
|
|
@"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<div class=""umb-macro-holder mceNonEditable"" test1=""value1"" test2=""value2"">
|
|
|
|
|
|
<!-- <?UMBRACO_MACRO test1=""value1"" test2=""value2"" macroAlias=""Map"" /> -->
|
|
|
|
|
|
<ins>Macro alias: <strong>Map</strong></ins></div>
|
|
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<div class=""umb-macro-holder mceNonEditable"" test1=""value1"" test2=""value2"">
|
|
|
|
|
|
<!-- <?UMBRACO_MACRO test1=""value1"" macroAlias=""Map"" test2=""value2"" /> -->
|
|
|
|
|
|
<ins>Macro alias: <strong>Map</strong></ins></div>
|
|
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<div class=""umb-macro-holder mceNonEditable"" test1=""value1"" test2=""value2"">
|
|
|
|
|
|
<!-- <?UMBRACO_MACRO macroAlias=""Map"" test1=""value1"" test2=""value2"" /> -->
|
|
|
|
|
|
<ins>Macro alias: <strong>Map</strong></ins></div>
|
2020-12-20 08:36:11 +01:00
|
|
|
|
<p>asdfasdf</p>".Replace(Environment.NewLine, string.Empty),
|
|
|
|
|
|
result.Replace(Environment.NewLine, string.Empty));
|
2018-06-29 19:52:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Format_RTE_Data_For_Editor_With_Multiple_Macros()
|
|
|
|
|
|
{
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string content = @"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<?UMBRACO_MACRO macroAlias=""Breadcrumb"" />
|
|
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
<?UMBRACO_MACRO macroAlias=""login"" />
|
|
|
|
|
|
<p> </p>";
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string result = MacroTagParser.FormatRichTextPersistedDataForEditor(content, new Dictionary<string, string>());
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
2020-12-20 08:36:11 +01:00
|
|
|
|
Assert.AreEqual(
|
|
|
|
|
|
@"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<div class=""umb-macro-holder mceNonEditable"">
|
|
|
|
|
|
<!-- <?UMBRACO_MACRO macroAlias=""Breadcrumb"" /> -->
|
|
|
|
|
|
<ins>Macro alias: <strong>Breadcrumb</strong></ins></div>
|
|
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
<div class=""umb-macro-holder mceNonEditable"">
|
|
|
|
|
|
<!-- <?UMBRACO_MACRO macroAlias=""login"" /> -->
|
|
|
|
|
|
<ins>Macro alias: <strong>login</strong></ins></div>
|
2020-12-20 08:36:11 +01:00
|
|
|
|
<p> </p>".Replace(Environment.NewLine, string.Empty),
|
|
|
|
|
|
result.Replace(Environment.NewLine, string.Empty));
|
2018-06-29 19:52:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Format_RTE_Data_For_Persistence_Multiline_Parameters()
|
|
|
|
|
|
{
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string content = @"<html>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<body>
|
|
|
|
|
|
<h1>asdfasdf</h1>
|
|
|
|
|
|
<div class='umb-macro-holder mceNonEditable' att1='asdf' att2='asdfasdfasdf' att3=""sdfsdfd"">
|
|
|
|
|
|
<!-- <?UMBRACO_MACRO macroAlias=""myMacro"" param1=""test1"" param2=""test2
|
|
|
|
|
|
dfdsfds"" /> -->
|
|
|
|
|
|
asdfasdf
|
|
|
|
|
|
asdfas
|
|
|
|
|
|
<span>asdfasdfasdf</span>
|
|
|
|
|
|
<p>asdfasdf</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<span>asdfdasf</span>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
asdfsdf
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</body>
|
|
|
|
|
|
</html>";
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string result = MacroTagParser.FormatRichTextContentForPersistence(content);
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
2020-12-20 08:36:11 +01:00
|
|
|
|
Assert.AreEqual(
|
|
|
|
|
|
@"<html>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<body>
|
|
|
|
|
|
<h1>asdfasdf</h1>
|
|
|
|
|
|
<?UMBRACO_MACRO macroAlias=""myMacro"" param1=""test1"" param2=""test2
|
|
|
|
|
|
dfdsfds"" />
|
|
|
|
|
|
<span>asdfdasf</span>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
asdfsdf
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</body>
|
2020-12-20 08:36:11 +01:00
|
|
|
|
</html>".Replace(Environment.NewLine, string.Empty),
|
|
|
|
|
|
result.Replace(Environment.NewLine, string.Empty));
|
2018-06-29 19:52:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Format_RTE_Data_For_Editor_With_Params_Closing_Tag()
|
|
|
|
|
|
{
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string content = @"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<?UMBRACO_MACRO macroAlias=""Map"" test1=""value1"" test2=""value2"" ></?UMBRACO_MACRO>
|
|
|
|
|
|
<p>asdfasdf</p>";
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string result = MacroTagParser.FormatRichTextPersistedDataForEditor(content, new Dictionary<string, string>() { { "test1", "value1" }, { "test2", "value2" } });
|
|
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(
|
|
|
|
|
|
@"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<div class=""umb-macro-holder mceNonEditable"" test1=""value1"" test2=""value2"">
|
|
|
|
|
|
<!-- <?UMBRACO_MACRO macroAlias=""Map"" test1=""value1"" test2=""value2"" /> -->
|
|
|
|
|
|
<ins>Macro alias: <strong>Map</strong></ins></div>
|
2020-12-20 08:36:11 +01:00
|
|
|
|
<p>asdfasdf</p>".Replace(Environment.NewLine, string.Empty),
|
|
|
|
|
|
result.Replace(Environment.NewLine, string.Empty));
|
2018-06-29 19:52:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Format_RTE_Data_For_Editor_With_Params_Closing_Tag_And_Content()
|
|
|
|
|
|
{
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string content = @"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<?UMBRACO_MACRO macroAlias=""Map"" test1=""value1"" test2=""value2"" ><img src='blah.jpg'/></?UMBRACO_MACRO>
|
|
|
|
|
|
<p>asdfasdf</p>";
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string result = MacroTagParser.FormatRichTextPersistedDataForEditor(content, new Dictionary<string, string>() { { "test1", "value1" }, { "test2", "value2" } });
|
|
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(
|
|
|
|
|
|
@"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<div class=""umb-macro-holder mceNonEditable"" test1=""value1"" test2=""value2"">
|
|
|
|
|
|
<!-- <?UMBRACO_MACRO macroAlias=""Map"" test1=""value1"" test2=""value2"" /> -->
|
|
|
|
|
|
<ins>Macro alias: <strong>Map</strong></ins></div>
|
2020-12-20 08:36:11 +01:00
|
|
|
|
<p>asdfasdf</p>".Replace(Environment.NewLine, string.Empty),
|
|
|
|
|
|
result.Replace(Environment.NewLine, string.Empty));
|
2018-06-29 19:52:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Format_RTE_Data_For_Editor_With_Multiline_Parameters()
|
|
|
|
|
|
{
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string content = @"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<?UMBRACO_MACRO macroAlias=""Map"" test1=""value1"" test2=""value2
|
|
|
|
|
|
test"" />
|
|
|
|
|
|
<p>asdfasdf</p>";
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string result = MacroTagParser.FormatRichTextPersistedDataForEditor(content, new Dictionary<string, string>() { { "test1", "value1" }, { "test2", "value2\r\ntest" } });
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
2020-12-20 08:36:11 +01:00
|
|
|
|
Assert.AreEqual(
|
|
|
|
|
|
@"<p>asdfasdf</p>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<p>asdfsadf</p>
|
|
|
|
|
|
<div class=""umb-macro-holder mceNonEditable"" test1=""value1"" test2=""value2
|
|
|
|
|
|
test"">
|
|
|
|
|
|
<!-- <?UMBRACO_MACRO macroAlias=""Map"" test1=""value1"" test2=""value2
|
|
|
|
|
|
test"" /> -->
|
|
|
|
|
|
<ins>Macro alias: <strong>Map</strong></ins></div>
|
2020-12-20 08:36:11 +01:00
|
|
|
|
<p>asdfasdf</p>".NoCrLf(),
|
|
|
|
|
|
result.NoCrLf());
|
2018-06-29 19:52:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Format_RTE_Data_For_Persistence()
|
|
|
|
|
|
{
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string content = @"<html>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<body>
|
|
|
|
|
|
<h1>asdfasdf</h1>
|
|
|
|
|
|
<div class='umb-macro-holder mceNonEditable' att1='asdf' att2='asdfasdfasdf' att3=""sdfsdfd"">
|
|
|
|
|
|
<!-- <?UMBRACO_MACRO macroAlias=""myMacro"" param1=""test1"" param2=""test2"" /> -->
|
|
|
|
|
|
asdfasdf
|
|
|
|
|
|
asdfas
|
|
|
|
|
|
<span>asdfasdfasdf</span>
|
|
|
|
|
|
<p>asdfasdf</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<span>asdfdasf</span>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
asdfsdf
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</body>
|
|
|
|
|
|
</html>";
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string result = MacroTagParser.FormatRichTextContentForPersistence(content);
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
2020-12-20 08:36:11 +01:00
|
|
|
|
Assert.AreEqual(
|
|
|
|
|
|
@"<html>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<body>
|
|
|
|
|
|
<h1>asdfasdf</h1>
|
|
|
|
|
|
<?UMBRACO_MACRO macroAlias=""myMacro"" param1=""test1"" param2=""test2"" />
|
|
|
|
|
|
<span>asdfdasf</span>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
asdfsdf
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</body>
|
2020-12-20 08:36:11 +01:00
|
|
|
|
</html>".Replace(Environment.NewLine, string.Empty),
|
|
|
|
|
|
result.Replace(Environment.NewLine, string.Empty));
|
2018-06-29 19:52:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Format_RTE_Data_For_Persistence_No_Class()
|
|
|
|
|
|
{
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string content = @"<html>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<body>
|
|
|
|
|
|
<h1>asdfasdf</h1>
|
|
|
|
|
|
<div att1='asdf' att2='asdfasdfasdf' att3=""sdfsdfd"">
|
|
|
|
|
|
<!-- <?UMBRACO_MACRO macroAlias=""myMacro"" param1=""test1"" param2=""test2"" /> -->
|
|
|
|
|
|
asdfasdf
|
|
|
|
|
|
asdfas
|
|
|
|
|
|
<span>asdfasdfasdf</span>
|
|
|
|
|
|
<p>asdfasdf</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<span>asdfdasf</span>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
asdfsdf
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</body>
|
|
|
|
|
|
</html>";
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string result = MacroTagParser.FormatRichTextContentForPersistence(content);
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
2020-12-20 08:36:11 +01:00
|
|
|
|
Assert.AreEqual(
|
|
|
|
|
|
@"<html>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<body>
|
|
|
|
|
|
<h1>asdfasdf</h1>
|
|
|
|
|
|
<?UMBRACO_MACRO macroAlias=""myMacro"" param1=""test1"" param2=""test2"" />
|
|
|
|
|
|
<span>asdfdasf</span>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
asdfsdf
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</body>
|
2020-12-20 08:36:11 +01:00
|
|
|
|
</html>".Replace(Environment.NewLine, string.Empty),
|
|
|
|
|
|
result.Replace(Environment.NewLine, string.Empty));
|
2018-06-29 19:52:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Format_RTE_Data_For_Persistence_Custom_Single_Entry()
|
|
|
|
|
|
{
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string content = @"<div class=""umb-macro-holder mceNonEditable umb-macro-mce_1""><!-- <?UMBRACO_MACRO macroAlias=""Test"" content=""1089"" textArea=""asdfasdf"" title="""" bool=""0"" number="""" contentType="""" multiContentType="""" multiProperties="""" properties="""" tabs="""" multiTabs="""" /> --><ins>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
<div class=""facts-box"">
|
|
|
|
|
|
<div class=""fatcs-box-header"">
|
|
|
|
|
|
<h3>null</h3>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class=""fatcs-box-body"">1089</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</ins></div>";
|
2020-12-20 08:36:11 +01:00
|
|
|
|
string result = MacroTagParser.FormatRichTextContentForPersistence(content);
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(@"<?UMBRACO_MACRO macroAlias=""Test"" content=""1089"" textArea=""asdfasdf"" title="""" bool=""0"" number="""" contentType="""" multiContentType="""" multiProperties="""" properties="""" tabs="""" multiTabs="""" />", result);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|