From fe00c8ad80f3340d495b8f724b0bf4489595ede2 Mon Sep 17 00:00:00 2001 From: tomatosalat0 Date: Sun, 9 Nov 2025 15:03:15 +0100 Subject: [PATCH] Rewrite of flaky test --- Jint.Tests/Runtime/AsyncTests.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Jint.Tests/Runtime/AsyncTests.cs b/Jint.Tests/Runtime/AsyncTests.cs index d63c605b2d..de80b155bd 100644 --- a/Jint.Tests/Runtime/AsyncTests.cs +++ b/Jint.Tests/Runtime/AsyncTests.cs @@ -1,5 +1,6 @@ using System.Collections.Concurrent; using Jint.Native; +using Jint.Runtime; using Jint.Tests.Runtime.TestClasses; namespace Jint.Tests.Runtime; @@ -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(() => result.UnwrapIfPromise(timeout)); + Assert.Equal($"Promise was rejected with value Timeout of {timeout} reached", exception.Message); } [Fact]