Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
Add test project ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
Freymaurer committed Jun 13, 2022
1 parent b886ce1 commit 9d7e4a1
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/Fornax.Nfdi4Plants.Tests/Fornax.Nfdi4Plants.Tests.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup>

<ItemGroup>
<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\Fornax.Nfdi4Plants\Fornax.Nfdi4Plants.fsproj" />
</ItemGroup>
</Project>
14 changes: 14 additions & 0 deletions tests/Fornax.Nfdi4Plants.Tests/Main.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Fornax.Nfdi4Plants.Tests

open Expecto

open Tests.MarkdigExtensions

let allTests = testList "" [
Nfdi4PlantsSidebarHeader.tests
Nfdi4PlantsHeader.tests
]

[<EntryPoint>]
let main argv =
runTestsWithCLIArgs [] [||] allTests
34 changes: 34 additions & 0 deletions tests/Fornax.Nfdi4Plants.Tests/nfdi-header.tests.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module Tests.MarkdigExtensions.Nfdi4PlantsHeader

open Expecto
open Fornax.Nfdi4Plants
open Fornax.Nfdi4Plants.MarkdigExtensions.NfdiHeader
open Markdig

let pipeline =
let builder = new MarkdownPipelineBuilder()
builder
.UseAdvancedExtensions()
.UseEmojiAndSmiley()
.UseNFDIHeader()
.Build()

[<Tests>]
let tests =
testList "UseNFDIHeader" [
test "basic case" {
let markdown = """# Start testing!"""
let result = Markdown.ToHtml(markdown, pipeline)
Expect.equal result $"""<nfdi-h1 id="start-testing">Start testing!</nfdi-h1>{'\010'}""" ""
}
test "5 depth case" {
let markdown = """##### Start testing!"""
let result = Markdown.ToHtml(markdown, pipeline)
Expect.equal result $"""<nfdi-h5 id="start-testing">Start testing!</nfdi-h5>{'\010'}""" ""
}
test "6 depth case" {
let markdown = """###### Start testing!"""
let result = Markdown.ToHtml(markdown, pipeline)
Expect.equal result $"""<nfdi-h6 id="start-testing">Start testing!</nfdi-h6>{'\010'}""" ""
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module Tests.MarkdigExtensions.Nfdi4PlantsSidebarHeader

open Expecto
open Fornax.Nfdi4Plants
open Fornax.Nfdi4Plants.MarkdigExtensions.NfdiSidebarElementHeader
open Markdig

let pipeline =
let builder = new MarkdownPipelineBuilder()
builder
.UseSidebarHeader()
.Build()

[<Tests>]
let tests =
testList "UseSidebarHeader" [
test "basic case" {
let markdown = """# Start testing!:#start-testing"""
let result = Markdown.ToHtml(markdown, pipeline)
Expect.equal result $"""<h1 slot="inner" href="#start-testing">Start testing!</h1>{'\010'}""" ""
}
test "base case without link" {
let markdown = """# Start testing!"""
let result = Markdown.ToHtml(markdown, pipeline)
Expect.equal result $"""<h1 slot="inner">Start testing!</h1>{'\010'}""" ""
}
test "6 depth case" {
let markdown = """###### Start testing!"""
let result = Markdown.ToHtml(markdown, pipeline)
Expect.equal result $"""<h3 slot="inner">Start testing!</h3>{'\010'}""" ""
}
]

0 comments on commit 9d7e4a1

Please sign in to comment.