forked from Blazor-Diagrams/Blazor.Diagrams
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from dou867/jstimeout
WI00709656 GetBoundingClientRect don't throw on time out
- Loading branch information
Showing
2 changed files
with
29 additions
and
1 deletion.
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
21 changes: 21 additions & 0 deletions
21
tests/Blazor.Diagrams.Tests/Extensions/JSRuntimeExtensionsTest.cs
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,21 @@ | ||
using Blazor.Diagrams.Core.Geometry; | ||
using Microsoft.JSInterop; | ||
using Moq; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using JSRuntimeExtensions = Blazor.Diagrams.Extensions.JSRuntimeExtensions; | ||
|
||
namespace Blazor.Diagrams.Tests.Extensions | ||
{ | ||
public class JSRuntimeExtensionsTest | ||
{ | ||
[Fact] | ||
public async Task TestGetBoundingClientRectDoesNotThrowOnTimeout() | ||
{ | ||
var jsRuntime = new Mock<IJSRuntime>(); | ||
jsRuntime.Setup(j => j.InvokeAsync<Rectangle>(It.IsAny<string>(), It.IsAny<object?[]?>())).ThrowsAsync(new TaskCanceledException()); | ||
var result = await JSRuntimeExtensions.GetBoundingClientRect(jsRuntime.Object, default); | ||
Assert.Null(result); | ||
} | ||
} | ||
} |