This repository has been archived by the owner on Oct 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a54f783
commit 7538a7f
Showing
3 changed files
with
49 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 4 additions & 7 deletions
11
tests/Nfdi4Plants.Fornax.Tests/Nfdi4Plants.Fornax.Tests.fsproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net5.0</TargetFramework> | ||
<GenerateProgramFile>false</GenerateProgramFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="nfdi-code.tests.fs" /> | ||
<Compile Include="nfdi-header.tests.fs" /> | ||
<Compile Include="nfdi-sidebar-element-header.tests.fs" /> | ||
<Compile Include="main.fs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Expecto" Version="9.*" /> | ||
<PackageReference Include="YoloDev.Expecto.TestSdk" Version="0.*" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.*" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Nfdi4Plants.Fornax\Nfdi4Plants.Fornax.fsproj" /> | ||
<ProjectReference Include="..\..\src\Nfdi4Plants.Fornax\Nfdi4Plants.Fornax.fsproj" /> | ||
</ItemGroup> | ||
</Project> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
module Tests.MarkdigExtensions.Nfdi4PlantsCodeBlock | ||
|
||
open Expecto | ||
open Fornax.Nfdi4Plants | ||
open Fornax.Nfdi4Plants.MarkdigExtensions.NfdiCode | ||
open Markdig | ||
|
||
let pipeline = | ||
let builder = new MarkdownPipelineBuilder() | ||
builder | ||
.UseAdvancedExtensions() | ||
.UseEmojiAndSmiley() | ||
.UseNFDICodeBlock() | ||
.Build() | ||
|
||
[<Tests>] | ||
let tests = | ||
testList "UseNFDICodeBlock" [ | ||
test "basic case" { | ||
let markdown = """Here is some inline `code`!""" | ||
let result = Markdown.ToHtml(markdown, pipeline) | ||
Expect.equal result $"""<p>Here is some inline <code>code</code>!</p>{'\010'}""" "" | ||
} | ||
test "Fenced code block, no language" { | ||
let markdown = """Test line | ||
``` | ||
let someCode = 42 | ||
``` | ||
""" | ||
let result = Markdown.ToHtml(markdown, pipeline).Trim() | ||
let expected = $"""<p>Test line</p>{'\010'}<nfdi-code>let someCode = 42</nfdi-code>""".Trim() | ||
Expect.equal result expected "" | ||
} | ||
test "Fenced code block" { | ||
let markdown = """Test line | ||
```fsharp | ||
let someCode = 42 | ||
``` | ||
""" | ||
let result = Markdown.ToHtml(markdown, pipeline) | ||
let expected = $"""<p>Test line</p>{'\010'}<nfdi-code class="language-fsharp">let someCode = 42</nfdi-code>""" | ||
Expect.equal result expected "" | ||
} | ||
] |