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.
This commit is contained in:
Sipke Schoorstra 2025-11-12 17:09:13 +01:00
parent 30c1f16c15
commit d84e97945c
No known key found for this signature in database
GPG key ID: 5C10502B28A4268F

View file

@ -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<IJavaScriptEvaluator>();
}
[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<Guid>(result);
}
}