Skip to content

Commit

Permalink
test(improvements): fix tests for Redo and Undo in the `UndoManag…
Browse files Browse the repository at this point in the history
…er` class
  • Loading branch information
LSViana committed Oct 31, 2023
1 parent 2366e0f commit 0dbb59c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
14 changes: 4 additions & 10 deletions Tests/YDotNet.Tests.Unit/UndoManagers/RedoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void RedoAddingAndUpdatingAndRemovingContentOnText()
{ "bold", Input.Boolean(value: true) }
}));
transaction.Commit();
undoManager.Redo();
undoManager.Undo();
result = undoManager.Redo();

transaction = doc.ReadTransaction();
Expand All @@ -67,7 +67,7 @@ public void RedoAddingAndUpdatingAndRemovingContentOnText()

// Assert
Assert.That(chunks.Length, Is.EqualTo(expected: 3));
Assert.That(result, Is.False);
Assert.That(result, Is.True);

// Act (remove, undo, and redo)
transaction = doc.WriteTransaction();
Expand Down Expand Up @@ -97,18 +97,12 @@ public void RedoAddingAndUpdatingAndRemovingContentOnArray()
var transaction = doc.WriteTransaction();
array.InsertRange(
transaction,
index: 0,
new[]
{
Input.Boolean(value: true),
Input.Long(value: 2469L),
Input.String("Lucas")
});
index: 0, Input.Boolean(value: true), Input.Long(value: 2469L), Input.String("Lucas"));
transaction.Commit();

// Act (add, undo, and redo)
transaction = doc.WriteTransaction();
array.InsertRange(transaction, index: 3, new[] { Input.Undefined() });
array.InsertRange(transaction, index: 3, Input.Undefined());
transaction.Commit();
undoManager.Undo();
var result = undoManager.Redo();
Expand Down
13 changes: 4 additions & 9 deletions Tests/YDotNet.Tests.Unit/UndoManagers/UndoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace YDotNet.Tests.Unit.UndoManagers;
public class UndoTests
{
[Test]
[Ignore("Waiting for fix on yffi.")]
public void ReturnsFalseWhenNoChangesApplied()
{
// Arrange
Expand Down Expand Up @@ -82,7 +83,7 @@ public void UndoAddingAndUpdatingAndRemovingContentOnText()
}

[Test]
[Ignore("There seems to be a bug in y-crdt.")]
[Ignore("Waiting for fix on yffi.")]
public void UndoAddingAndUpdatingAndRemovingContentOnArray()
{
// Arrange
Expand All @@ -92,18 +93,12 @@ public void UndoAddingAndUpdatingAndRemovingContentOnArray()
var transaction = doc.WriteTransaction();
array.InsertRange(
transaction,
index: 0,
new[]
{
Input.Boolean(value: true),
Input.Long(value: 2469L),
Input.String("Lucas")
});
index: 0, Input.Boolean(value: true), Input.Long(value: 2469L), Input.String("Lucas"));
transaction.Commit();

// Act (add and undo)
transaction = doc.WriteTransaction();
array.InsertRange(transaction, index: 3, new[] { Input.Undefined() });
array.InsertRange(transaction, index: 3, Input.Undefined());
transaction.Commit();
var result = undoManager.Undo();

Expand Down

0 comments on commit 0dbb59c

Please sign in to comment.