From de756095bdc4cfda33d66656c77e742fa783ee68 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 18 Dec 2023 13:01:10 +0100 Subject: [PATCH] Sanitize expected string. --- .../Model/Contents/RichTextTests.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Contents/RichTextTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Contents/RichTextTests.cs index fc593ba5a7..726ff8bb7c 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Contents/RichTextTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Contents/RichTextTests.cs @@ -27,7 +27,7 @@ public void Should_format_to_html() { var expected = File.ReadAllText("Model/Contents/ComplexText.html"); - Assert.Equal(expected.Trim(), node.ToHtml().Trim()); + Assert.Equal(Sanitize(expected), Sanitize(node.ToHtml())); } [Fact] @@ -35,7 +35,7 @@ public void Should_format_to_minimized_html() { var expected = File.ReadAllText("Model/Contents/ComplexText.min.html"); - Assert.Equal(expected.Trim(), node.ToHtml(0).Trim()); + Assert.Equal(Sanitize(expected), Sanitize(node.ToHtml(0))); } [Fact] @@ -43,7 +43,7 @@ public void Should_format_to_markdown() { var expected = File.ReadAllText("Model/Contents/ComplexText.md"); - Assert.Equal(expected.Trim(), node.ToMarkdown().Trim()); + Assert.Equal(Sanitize(expected), Sanitize(node.ToMarkdown())); } [Fact] @@ -51,6 +51,11 @@ public void Should_format_to_text() { var expected = File.ReadAllText("Model/Contents/ComplexText.txt"); - Assert.Equal(expected.Trim(), node.ToText().Trim()); + Assert.Equal(Sanitize(expected), Sanitize(node.ToText())); + } + + private static string Sanitize(string source) + { + return source.Replace("\r\n", "\n").Trim(); } }