Skip to content

Commit

Permalink
More listener ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
desplesda committed Jun 27, 2023
1 parent 10d01e7 commit 4922514
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions YarnSpinner.LanguageServer.Tests/LanguageServerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ public async Task Server_OnChangingDocument_SendsNodesChangedNotification()

nodeInfo.Nodes.Should().HaveCount(2, "because there are two nodes in the file before we make changes");

ChangeTextInDocument(client, filePath, new Position(20, 0), "title: Node3\n---\n===\n");

nodeInfo = await GetNodesChangedNotificationAsync((nodesResult) =>
nodesResult.Uri.AbsolutePath.Contains(Path.Combine("Project1", "Test.yarn"))
var nodesChanged = GetNodesChangedNotificationAsync((nodesResult) =>
nodesResult.Uri.AbsolutePath.Contains(filePath)
);
ChangeTextInDocument(client, filePath, new Position(20, 0), "title: Node3\n---\n===\n");
nodeInfo = await nodesChanged;

nodeInfo.Nodes.Should().HaveCount(3, "because we added a new node");
nodeInfo.Nodes.Should().Contain(n => n.Title == "Node3", "because the new node we added has this title");
Expand All @@ -132,22 +132,24 @@ public async Task Server_OnChangingDocument_SendsNodesChangedNotification()
[Fact]
public async Task Server_OnInvalidChanges_ProducesSyntaxErrors()
{
Task<PublishDiagnosticsParams> getInitialDiagnosticsTask = GetDiagnosticsAsync();
Task<PublishDiagnosticsParams> getDiagnosticsTask = GetDiagnosticsAsync();

var (client, server) = await Initialize(ConfigureClient, ConfigureServer);

{
var errors = (await getInitialDiagnosticsTask).Diagnostics.Where(d => d.Severity == DiagnosticSeverity.Error);
var errors = (await getDiagnosticsTask).Diagnostics.Where(d => d.Severity == DiagnosticSeverity.Error);

errors.Should().BeNullOrEmpty("because the original project contains no syntax errors");
}

// Introduce an error
var filePath = Path.Combine(TestUtility.PathToTestWorkspace, "Project1", "Test.yarn");
getDiagnosticsTask = GetDiagnosticsAsync(diags => diags.Uri.ToString().Contains(filePath));

ChangeTextInDocument(client, filePath, new Position(9, 0), "<<set");

{
var diagnosticsResult = await GetDiagnosticsAsync(diags => diags.Uri.ToString().Contains(filePath));
var diagnosticsResult = await getDiagnosticsTask;

var enumerable = diagnosticsResult.Diagnostics;

Expand All @@ -157,10 +159,11 @@ public async Task Server_OnInvalidChanges_ProducesSyntaxErrors()
}

// Remove the error
getDiagnosticsTask = GetDiagnosticsAsync(diags => diags.Uri.ToString().Contains(filePath));
ChangeTextInDocument(client, filePath, new Position(9, 0), new Position(9, 5), "");

{
PublishDiagnosticsParams diagnosticsResult = await GetDiagnosticsAsync(diags => diags.Uri.ToString().Contains(filePath));
PublishDiagnosticsParams diagnosticsResult = await getDiagnosticsTask;

var errors = diagnosticsResult.Diagnostics.Where(d => d.Severity == DiagnosticSeverity.Error);

Expand Down

0 comments on commit 4922514

Please sign in to comment.