Add JSON text renderer (#1086)

* Add JsonText widget to render highlighted JSON

Closes #1051
This commit is contained in:
Patrik Svensson
2022-12-31 19:17:15 +01:00
committed by GitHub
parent 3e6e0990c5
commit 54be64ec84
48 changed files with 1634 additions and 21 deletions

View File

@ -0,0 +1,23 @@
namespace Spectre.Console.Tests.Unit;
[UsesVerify]
[ExpectationPath("Widgets/Json")]
public sealed class JsonTextTests
{
[Fact]
[Expectation("Render_Json")]
public Task Should_Render_Json()
{
// Given
var console = new TestConsole().Size(new Size(80, 15));
var json = EmbeddedResourceReader
.LoadResourceStream("Spectre.Console.Tests/Data/example.json")
.ReadText();
// When
console.Write(new Panel(new JsonText(json)).Header("Some JSON"));
// Then
return Verifier.Verify(console.Output);
}
}