Skip to content
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Elsa.Studio.Models;
using Xunit;

namespace Elsa.Studio.Core.Tests;

public class DisplayInputEditorContextTests
{
[Fact]
public async Task UpdateValueAsync_UpdatesValue()
{
var context = new DisplayInputEditorContext
{
Value = "old",
OnValueChanged = _ => Task.CompletedTask
};

await context.UpdateValueAsync("new");

Assert.Equal("new", context.Value);
}

[Fact]
public async Task UpdateValueAsync_UpdatesValueBeforeNotifying()
{
object? valueSeenByHandler = null;
var context = new DisplayInputEditorContext { Value = "old" };
context.OnValueChanged = _ =>
{
valueSeenByHandler = context.Value;
return Task.CompletedTask;
};

await context.UpdateValueAsync("new");

Assert.Equal("new", valueSeenByHandler);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public string GetExpressionValueOrDefault()
/// </summary>
public async Task UpdateValueAsync(object? value)
{
Value = value;
await OnValueChanged(value);
}

Expand Down
Loading