Skip to content

Commit 74f0ba1

Browse files
committed
Bootstrap all tests with a yaml front matter unless already provided or the content is explicitly empty
1 parent c10870f commit 74f0ba1

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

tests/Elastic.Markdown.Tests/Directives/DirectiveBaseTests.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,16 @@ protected DirectiveTest(ITestOutputHelper output, [LanguageInjection("markdown")
5959
var logger = new TestLoggerFactory(output);
6060
FileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
6161
{
62-
{ "docs/source/index.md", new MockFileData(content) }
62+
{ "docs/source/index.md", new MockFileData(string.IsNullOrEmpty(content) || content.StartsWith("---") ? content :
63+
// language=markdown
64+
$"""
65+
---
66+
title: Test Document
67+
---
68+
69+
{content}
70+
"""
71+
)}
6372
}, new MockFileSystemOptions
6473
{
6574
CurrentDirectory = Paths.Root.FullName

tests/Elastic.Markdown.Tests/Inline/AnchorLinkTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ namespace Elastic.Markdown.Tests.Inline;
1212

1313
public abstract class AnchorLinkTestBase(ITestOutputHelper output, [LanguageInjection("markdown")] string content)
1414
: InlineTest<LinkInline>(output,
15-
$"""
16-
## Hello world
15+
$"""
16+
## Hello world
1717
18-
A paragraph
18+
A paragraph
1919
20-
{content}
20+
{content}
2121
22-
""")
22+
""")
2323
{
2424
protected override void AddToFileSystem(MockFileSystem fileSystem)
2525
{

tests/Elastic.Markdown.Tests/Inline/InlneBaseTests.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,16 @@ protected InlineTest(ITestOutputHelper output, [LanguageInjection("markdown")]st
6969
var logger = new TestLoggerFactory(output);
7070
FileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
7171
{
72-
{ "docs/source/index.md", new MockFileData(content) }
72+
{ "docs/source/index.md", new MockFileData(string.IsNullOrEmpty(content) || content.StartsWith("---") ? content :
73+
// language=markdown
74+
$"""
75+
---
76+
title: Test Document
77+
---
78+
79+
{content}
80+
"""
81+
)}
7382
}, new MockFileSystemOptions
7483
{
7584
CurrentDirectory = Paths.Root.FullName

0 commit comments

Comments
 (0)