elsa-core/test/integration/Elsa.JavaScript.IntegrationTests/GuidTests.cs
Sipke Schoorstra d84e97945c
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.
2025-11-12 17:09:13 +01:00

33 lines
984 B
C#

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);
}
}