Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix whitespace in Pester symbol and add test #1893

Merged
merged 2 commits into from
Aug 15, 2022
Merged
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
Expand Up @@ -199,7 +199,7 @@ internal PesterSymbolReference(
IScriptExtent scriptExtent)
: base(
SymbolType.Function,
testLine.TrimEnd(DefinitionTrimChars),
testLine.TrimStart().TrimEnd(DefinitionTrimChars),
scriptExtent,
scriptFile.FilePath,
testLine)
Expand Down
22 changes: 20 additions & 2 deletions test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,26 @@ public void FindsSymbolsInFile()
[Fact]
public void FindsSymbolsInPesterFile()
{
List<SymbolReference> symbolsResult = FindSymbolsInFile(FindSymbolsInPesterFile.SourceDetails);
Assert.Equal(5, symbolsResult.Count);
List<PesterSymbolReference> symbolsResult = FindSymbolsInFile(FindSymbolsInPesterFile.SourceDetails).OfType<PesterSymbolReference>().ToList();
Assert.Equal(5, symbolsResult.Count(r => r.SymbolType == SymbolType.Function));

Assert.Equal(1, symbolsResult.Count(r => r.Command == PesterCommandType.Describe));
SymbolReference firstDescribeSymbol = symbolsResult.First(r => r.Command == PesterCommandType.Describe);
Assert.Equal("Describe \"A dummy test\"", firstDescribeSymbol.SymbolName);
Assert.Equal(1, firstDescribeSymbol.ScriptRegion.StartLineNumber);
Assert.Equal(1, firstDescribeSymbol.ScriptRegion.StartColumnNumber);

Assert.Equal(1, symbolsResult.Count(r => r.Command == PesterCommandType.Context));
SymbolReference firstContextSymbol = symbolsResult.First(r => r.Command == PesterCommandType.Context);
Assert.Equal("Context \"When a pester file is given\"", firstContextSymbol.SymbolName);
Assert.Equal(2, firstContextSymbol.ScriptRegion.StartLineNumber);
Assert.Equal(5, firstContextSymbol.ScriptRegion.StartColumnNumber);

Assert.Equal(3, symbolsResult.Count(r => r.Command == PesterCommandType.It));
SymbolReference lastItSymbol = symbolsResult.Last(r => r.Command == PesterCommandType.It);
Assert.Equal("It \"Should return describe symbols\"", lastItSymbol.SymbolName);
Assert.Equal(11, lastItSymbol.ScriptRegion.StartLineNumber);
Assert.Equal(9, lastItSymbol.ScriptRegion.StartColumnNumber);
}

[Fact]
Expand Down