Skip to content

Commit

Permalink
Fixup async command tests
Browse files Browse the repository at this point in the history
  • Loading branch information
desplesda committed Sep 18, 2023
1 parent 5179d86 commit 0b1b92e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions YarnSpinner.LanguageServer.Tests/CommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ public async Task Server_OnAddNodeCommand_ReturnsTextEdit()
result.Edits.Should().NotBeNullOrEmpty();
result.TextDocument.Uri.ToString().Should().Be("file://" + filePath);

Task<NodesChangedParams> nodesChangedAfterChangingText = GetNodesChangedNotificationAsync(n => n.Uri.ToString().Contains(filePath));

ChangeTextInDocument(client, result);

nodeInfo = await GetNodesChangedNotificationAsync(n => n.Uri.ToString().Contains(filePath));
nodeInfo = await nodesChangedAfterChangingText;

nodeInfo.Nodes.Should().HaveCount(5, "because we added a node");
nodeInfo.Nodes.Should()
Expand All @@ -123,6 +125,9 @@ public async Task Server_OnRemoveNodeCommand_ReturnsTextEdit()

nodeInfo.Nodes.Should().HaveCount(4, "because the file has four nodes");

// Expect to receive a 'nodes changed' notification
Task<NodesChangedParams> nodesChangedAfterRemovingNode = GetNodesChangedNotificationAsync(n => n.Uri.ToString().Contains(filePath));

var result = await client.ExecuteCommand(new ExecuteCommandParams<TextDocumentEdit>
{
Command = Commands.RemoveNode,
Expand All @@ -138,7 +143,7 @@ public async Task Server_OnRemoveNodeCommand_ReturnsTextEdit()

ChangeTextInDocument(client, result);

nodeInfo = await GetNodesChangedNotificationAsync(n => n.Uri.ToString().Contains(filePath));
nodeInfo = await nodesChangedAfterRemovingNode;

nodeInfo.Nodes.Should().HaveCount(3, "because we removed a node");
}
Expand Down Expand Up @@ -177,9 +182,11 @@ public async Task Server_OnUpdateHeaderCommand_ReturnsTextEditCreatingHeader()
result.Edits.Should().NotBeNullOrEmpty();
result.TextDocument.Uri.ToString().Should().Be("file://" + getInitialNodesChanged);

Task<NodesChangedParams> nodesChangedAfterChangingText = GetNodesChangedNotificationAsync(n => n.Uri.ToString().Contains(getInitialNodesChanged));

ChangeTextInDocument(client, result);

nodeInfo = await GetNodesChangedNotificationAsync(n => n.Uri.ToString().Contains(getInitialNodesChanged));
nodeInfo = await nodesChangedAfterChangingText;

nodeInfo.Nodes.Should()
.Contain(n => n.Title == "Start")
Expand Down Expand Up @@ -230,9 +237,11 @@ public async Task Server_OnUpdateHeaderCommand_ReturnsTextEditModifyingHeader()
result.Edits.Should().NotBeNullOrEmpty();
result.TextDocument.Uri.ToString().Should().Be("file://" + filePath);

Task<NodesChangedParams> nodesChangedAfterChangingText = GetNodesChangedNotificationAsync(n => n.Uri.ToString().Contains(filePath));

ChangeTextInDocument(client, result);

nodeInfo = await GetNodesChangedNotificationAsync(n => n.Uri.ToString().Contains(filePath));
nodeInfo = await nodesChangedAfterChangingText;

nodeInfo.Nodes.Should()
.Contain(n => n.Title == "Node2")
Expand Down

0 comments on commit 0b1b92e

Please sign in to comment.