Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Jint.Tests/Runtime/AsyncTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Concurrent;
using Jint.Native;
using Jint.Runtime;
using Jint.Tests.Runtime.TestClasses;

namespace Jint.Tests.Runtime;
Expand Down Expand Up @@ -43,13 +44,14 @@ public void ShouldReturnedTaskConvertedToPromiseInJS()
}

[Fact]
public void ShouldUnwrapPromiseWithCustomTimeout()
public void ShouldRespectCustomProvidedTimeoutWhenUnwrapping()
{
Engine engine = new(options => options.ExperimentalFeatures = ExperimentalFeature.TaskInterop);
engine.SetValue("asyncTestClass", new AsyncTestClass());
var result = engine.Evaluate("asyncTestClass.ReturnDelayedTaskAsync().then(x=>x)");
result = result.UnwrapIfPromise(TimeSpan.FromMilliseconds(200));
Assert.Equal(AsyncTestClass.TestString, result);
var timeout = TimeSpan.FromMilliseconds(1);
var exception = Assert.Throws<PromiseRejectedException>(() => result.UnwrapIfPromise(timeout));
Assert.Equal($"Promise was rejected with value Timeout of {timeout} reached", exception.Message);
}

[Fact]
Expand Down