Skip to content

Commit

Permalink
Adds a test to verify layout metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
daveaglick committed Jul 3, 2020
1 parent 30c5c81 commit 2bd3276
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/Statiq.Web/Templates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ internal Templates()
.WithLayout(Config.FromDocument((doc, ctx) =>
{
// Crawl up the tree looking for a layout
// TODO: Layout doesn't appear to be working, need to run that down
IDocument parent = doc;
while (parent != null)
{
Expand Down
39 changes: 39 additions & 0 deletions tests/Statiq.Web.Tests/Pipelines/ContentFixture.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using NUnit.Framework;
Expand Down Expand Up @@ -102,6 +103,44 @@ public async Task DocumentGatherHeadingsLevelSetting()
.Select(x => x.GetContentStringAsync().Result)
.ShouldBe(new[] { "1.1", "1.2", "2.1", "2.2", "2.3" }, true);
}

[Test]
public async Task LayoutMetadata()
{
// Given
Bootstrapper bootstrapper = Bootstrapper
.Factory
.CreateWeb(Array.Empty<string>());
TestFileProvider fileProvider = new TestFileProvider
{
{
"/input/Layout/Test.md",
@"Layout: _Layout.cshtml
---
# Heading
This is a test"
},
{
"/input/Layout/_Layout.cshtml",
@"<div>LAYOUT</div>
@RenderBody()"
},
};

// When
BootstrapperTestResult result = await bootstrapper.RunTestAsync(fileProvider);

// Then
result.ExitCode.ShouldBe((int)ExitCode.Normal);
IDocument document = result.Outputs[nameof(Content)][Phase.Output].ShouldHaveSingleItem();
(await document.GetContentStringAsync()).ShouldBe(
@"<div>LAYOUT</div>
<h1 id=""heading"">Heading</h1>
<p>This is a test</p>
",
StringCompareShould.IgnoreLineEndings);
}
}

public const string GatherHeadingsFile = @"
Expand Down

0 comments on commit 2bd3276

Please sign in to comment.