-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added clear history & history encryption
- Loading branch information
Showing
5 changed files
with
119 additions
and
5 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
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
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
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
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,90 @@ | ||
using InertiaCore.Models; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace InertiaCoreTests; | ||
|
||
public partial class Tests | ||
{ | ||
[Test] | ||
[Description("Test if history encryption is sent correctly.")] | ||
public void TestHistoryEncryptionResult() | ||
{ | ||
_factory.EncryptHistory(); | ||
|
||
var response = _factory.Render("Test/Page", new | ||
{ | ||
Test = "Test" | ||
}); | ||
|
||
var headers = new HeaderDictionary | ||
{ | ||
{ "X-Inertia", "true" } | ||
}; | ||
|
||
var context = PrepareContext(headers); | ||
|
||
response.SetContext(context); | ||
response.ProcessResponse(); | ||
|
||
var result = response.GetResult(); | ||
|
||
Assert.Multiple(() => | ||
{ | ||
Assert.That(result, Is.InstanceOf(typeof(JsonResult))); | ||
|
||
var json = (result as JsonResult)?.Value; | ||
Assert.That(json, Is.InstanceOf(typeof(Page))); | ||
|
||
Assert.That((json as Page)?.ClearHistory, Is.EqualTo(false)); | ||
Assert.That((json as Page)?.EncryptHistory, Is.EqualTo(true)); | ||
Assert.That((json as Page)?.Component, Is.EqualTo("Test/Page")); | ||
Assert.That((json as Page)?.Props, Is.EqualTo(new Dictionary<string, object?> | ||
{ | ||
{ "test", "Test" }, | ||
{ "errors", new Dictionary<string, string>(0) } | ||
})); | ||
}); | ||
} | ||
|
||
[Test] | ||
[Description("Test if clear history is sent correctly.")] | ||
public void TestClearHistoryResult() | ||
{ | ||
_factory.ClearHistory(); | ||
|
||
var response = _factory.Render("Test/Page", new | ||
{ | ||
Test = "Test" | ||
}); | ||
|
||
var headers = new HeaderDictionary | ||
{ | ||
{ "X-Inertia", "true" } | ||
}; | ||
|
||
var context = PrepareContext(headers); | ||
|
||
response.SetContext(context); | ||
response.ProcessResponse(); | ||
|
||
var result = response.GetResult(); | ||
|
||
Assert.Multiple(() => | ||
{ | ||
Assert.That(result, Is.InstanceOf(typeof(JsonResult))); | ||
|
||
var json = (result as JsonResult)?.Value; | ||
Assert.That(json, Is.InstanceOf(typeof(Page))); | ||
|
||
Assert.That((json as Page)?.ClearHistory, Is.EqualTo(true)); | ||
Assert.That((json as Page)?.EncryptHistory, Is.EqualTo(false)); | ||
Assert.That((json as Page)?.Component, Is.EqualTo("Test/Page")); | ||
Assert.That((json as Page)?.Props, Is.EqualTo(new Dictionary<string, object?> | ||
{ | ||
{ "test", "Test" }, | ||
{ "errors", new Dictionary<string, string>(0) } | ||
})); | ||
}); | ||
} | ||
} |