Skip to content

Commit 4f063ed

Browse files
committed
- Fix failing integration test by normalizing NewLine in output comparison.
1 parent 8254b60 commit 4f063ed

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

Rock.Tests.Integration/Core/Lava/Engine/LavaCommentsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ public void ShorthandLineComment_WithLeadingWhiteSpace_RendersLineWithWhiteSpace
396396
var input = "Line 1\n //-\nLine 2";
397397
var expectedOutput = "Line 1\n \nLine 2";
398398

399-
var renderOptions = new LavaTestRenderOptions { IgnoreWhiteSpace = false };
399+
var renderOptions = new LavaTestRenderOptions { IgnoreWhiteSpace = false, NormalizeNewLine = true };
400400
var result = TestHelper.GetTemplateRenderResult( typeof( FluidEngine ), input, options: renderOptions );
401401

402402
TestHelper.AssertTemplateOutput( typeof( FluidEngine ), expectedOutput, input, options: renderOptions );

Rock.Tests.Shared/Lava/LavaIntegrationTestHelper.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,11 @@ public void AssertTemplateOutput( ILavaEngine engine, IEnumerable<LavaTestOutput
756756
outputCompareText = Regex.Replace( outputCompareText, @"\s*", string.Empty );
757757
}
758758

759+
if ( options.NormalizeNewLine )
760+
{
761+
outputCompareText = Regex.Replace( outputCompareText, @"\r\n", "\n" );
762+
}
763+
759764
if ( options.IgnoreCase )
760765
{
761766
outputCompareText = outputCompareText.ToLower();

Rock.Tests.Shared/Lava/LavaTestRenderOptions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ public static LavaTestRenderOptions New
9393

9494
public bool IgnoreWhiteSpace = true;
9595
public bool IgnoreCase = false;
96+
/// <summary>
97+
/// When enabled, newline differences (CRLF vs LF) will be normalized (into LF which is \n) before comparison.
98+
/// </summary>
99+
public bool NormalizeNewLine = false;
96100

97101
public List<string> Wildcards = new List<string>();
98102

0 commit comments

Comments
 (0)