mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-07-01 18:38:16 +08:00
Add JSON text renderer (#1086)
* Add JsonText widget to render highlighted JSON Closes #1051
This commit is contained in:
23
test/Spectre.Console.Tests/Unit/Widgets/JsonTextTests.cs
Normal file
23
test/Spectre.Console.Tests/Unit/Widgets/JsonTextTests.cs
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user