From d84e97945cedc736f20ce1ca53fbed171581f011 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Wed, 12 Nov 2025 17:09:13 +0100 Subject: [PATCH] Add integration test for `newGuid()` in JavaScript evaluator. Introduces a new unit test in `Elsa.JavaScript.IntegrationTests` to verify that the `newGuid()` function in the JavaScript evaluator correctly returns a `Guid` type. --- .../GuidTests.cs | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/integration/Elsa.JavaScript.IntegrationTests/GuidTests.cs diff --git a/test/integration/Elsa.JavaScript.IntegrationTests/GuidTests.cs b/test/integration/Elsa.JavaScript.IntegrationTests/GuidTests.cs new file mode 100644 index 000000000..a46e1aa4b --- /dev/null +++ b/test/integration/Elsa.JavaScript.IntegrationTests/GuidTests.cs @@ -0,0 +1,33 @@ +using Elsa.Expressions.Models; +using Elsa.JavaScript.Contracts; +using Elsa.Testing.Shared; +using Microsoft.Extensions.DependencyInjection; +using Xunit.Abstractions; + +namespace Elsa.JavaScript.IntegrationTests; + +public class GuidTests +{ + private readonly IJavaScriptEvaluator _evaluator; + private readonly IServiceProvider _serviceProvider; + + public GuidTests(ITestOutputHelper testOutputHelper) + { + _serviceProvider = new TestApplicationBuilder(testOutputHelper).Build(); + _evaluator = _serviceProvider.GetRequiredService(); + } + + [Fact] + public async Task NewGuidReturnsGuid() + { + //Setup + var script = "newGuid()"; + var expressionExecutionContext = new ExpressionExecutionContext(_serviceProvider, new()); + + //Act + var result = (Guid)(await _evaluator.EvaluateAsync(script, typeof(Guid), expressionExecutionContext))!; + + //Assert + Assert.IsType(result); + } +} \ No newline at end of file