Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Contentstack.Utils.Tests/DefaultRenderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ public void testLinkhDocument()

string result = defaultRender.RenderNode("a", nodeLink, (nodes) => { return text; });

Assert.Equal($"<a href=\"{nodeLink.attrs["url"]}\" target=\"{nodeLink.attrs["target"]}\" title=\"{nodeLink.attrs["title"]}\" >Text To set Link</a>", result);
string url = nodeLink.attrs.ContainsKey("url") ? (string)nodeLink.attrs["url"] : "";
string target = nodeLink.attrs.ContainsKey("target") ? (string)nodeLink.attrs["target"] : "";
string title = nodeLink.attrs.ContainsKey("title") ? (string)nodeLink.attrs["title"] : "";

Assert.Equal($"<a href=\"{url}\" target=\"{target}\" title=\"{title}\" >Text To set Link</a>", result);
}

[Fact]
Expand Down
11 changes: 11 additions & 0 deletions Contentstack.Utils/Constants/ErrorMessages.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Contentstack.Utils.Constants
{
/// <summary>
/// Centralized error messages for the Contentstack Utils library
/// </summary>
public static class ErrorMessages
{
public const string InvalidRteJson = "Invalid RTE JSON. Provide a valid JSON structure and try again.";
}
}

1 change: 1 addition & 0 deletions Contentstack.Utils/Contentstack.Utils.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<Folder Include="Enums\" />
<Folder Include="Extensions\" />
<Folder Include="Converters\" />
<Folder Include="Constants\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.46" />
Expand Down
3 changes: 2 additions & 1 deletion Contentstack.Utils/Converters/RTEJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
using System.Reflection;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Contentstack.Utils.Constants;

namespace Contentstack.Utils.Converters
{
public class RTEJsonConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
throw new NotImplementedException();
throw new InvalidOperationException(ErrorMessages.InvalidRteJson);
}

public override object ReadJson(JsonReader reader, Type objectType,
Expand Down
Loading