Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yufeih committed Jun 5, 2023
1 parent f28165a commit c0f0f3b
Showing 1 changed file with 44 additions and 16 deletions.
60 changes: 44 additions & 16 deletions test/docfx.Tests/DocsetTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Runtime.CompilerServices;

using System.Text.Json;
using Microsoft.DocAsCode.Tests.Common;

using Xunit;
Expand Down Expand Up @@ -41,14 +41,14 @@ public static async Task CustomLogo_Override_LogoFromTemplate()
{
["docfx.json"] =
"""
{
"build": {
"resource": [{ "files": [ "logo.svg" ] }],
"template": ["default"],
"dest": "_site"
}
{
"build": {
"resource": [{ "files": [ "logo.svg" ] }],
"template": ["default"],
"dest": "_site"
}
""",
}
""",
["logo.svg"] = "<svg>my svg</svg>"
});

Expand All @@ -62,18 +62,46 @@ public static async Task Load_Custom_Plugin_From_Template()
{
["docfx.json"] =
"""
{
"build": {
"content": [{ "files": [ "*.md" ] }],
"template": ["default", "../../Assets/template"],
"dest": "_site",
"postProcessors": ["CustomPostProcessor"]
}
{
"build": {
"content": [{ "files": [ "*.md" ] }],
"template": ["default", "../../Assets/template"],
"dest": "_site",
"postProcessors": ["CustomPostProcessor"]
}
""",
}
""",
["index.md"] = ""
});

Assert.Equal("customPostProcessor", outputs["customPostProcessor.txt"]());
}

[Fact]
public static async Task Build_With_Global_Metadata_Files()
{
var outputs = await Build(new()
{
["docfx.json"] =
"""
{
"build": {
"content": [{ "files": [ "*.md" ] }],
"dest": "_site",
"exportRawModel": true,
"globalMetadataFiles": "projectMetadata.json"
}
}
""",
["projectMetadata.json"] =
"""
{
"_appTitle": "Something Really Stupid",
}
""",
["index.md"] = ""
});

Assert.Equal("Something Really Stupid", JsonDocument.Parse(outputs["index.raw.json"]()).RootElement.GetProperty("_appTitle").GetString());
}
}

0 comments on commit c0f0f3b

Please sign in to comment.