mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-19 07:25:27 +02:00
test(aliases): Add more rename tests
This commit is contained in:
parent
1a70a5ad57
commit
ea2e531393
@ -28,7 +28,7 @@ support: alice, bob
|
|||||||
t.Fatalf("Expected no errors, but got: %v", errors)
|
t.Fatalf("Expected no errors, but got: %v", errors)
|
||||||
}
|
}
|
||||||
|
|
||||||
edits := RenameAlias(i, i.Keys["alice"], "amelie")
|
edits := RenameAlias(i, "alice", "amelie")
|
||||||
|
|
||||||
if !(len(edits) == 3) {
|
if !(len(edits) == 3) {
|
||||||
t.Errorf("Expected 2 edits, but got %v", len(edits))
|
t.Errorf("Expected 2 edits, but got %v", len(edits))
|
||||||
@ -46,3 +46,38 @@ support: alice, bob
|
|||||||
t.Errorf("Unexpected edit: %v", edits[2])
|
t.Errorf("Unexpected edit: %v", edits[2])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRenameWithoutDefinitionEntry(
|
||||||
|
t *testing.T,
|
||||||
|
) {
|
||||||
|
input := utils.Dedent(`
|
||||||
|
bob: root
|
||||||
|
support: root, bob
|
||||||
|
`)
|
||||||
|
parser := ast.NewAliasesParser()
|
||||||
|
errors := parser.Parse(input)
|
||||||
|
|
||||||
|
if len(errors) > 0 {
|
||||||
|
t.Fatalf("Unexpected errors: %v", errors)
|
||||||
|
}
|
||||||
|
|
||||||
|
i, errors := indexes.CreateIndexes(parser)
|
||||||
|
|
||||||
|
if len(errors) > 0 {
|
||||||
|
t.Fatalf("Expected no errors, but got: %v", errors)
|
||||||
|
}
|
||||||
|
|
||||||
|
edits := RenameAlias(i, "root", "amelie")
|
||||||
|
|
||||||
|
if !(len(edits) == 2) {
|
||||||
|
t.Errorf("Expected 2 edits, but got %v", len(edits))
|
||||||
|
}
|
||||||
|
|
||||||
|
if !(edits[0].Range.Start.Line == 0 && edits[0].Range.Start.Character == 5 && edits[0].Range.End.Line == 0 && edits[0].Range.End.Character == 9) {
|
||||||
|
t.Errorf("Unexpected edit: %v", edits[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
if !(edits[1].Range.Start.Line == 1 && edits[1].Range.Start.Character == 9 && edits[1].Range.End.Line == 1 && edits[1].Range.End.Character == 13) {
|
||||||
|
t.Errorf("Unexpected edit: %v", edits[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user