73 lines
2.0 KiB
Go
73 lines
2.0 KiB
Go
package fourslash_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/fourslash"
|
|
. "efprojects.com/kitten-ipc/kitcom/internal/tsgo/fourslash/tests/util"
|
|
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/lsp/lsproto"
|
|
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/testutil"
|
|
)
|
|
|
|
func TestCompletionsKeyof(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
|
|
const content = `interface A { a: number; };
|
|
interface B { a: number; b: number; };
|
|
function f<T extends keyof A>(key: T) {}
|
|
f("[|/*f*/|]");
|
|
function g<T extends keyof B>(key: T) {}
|
|
g("[|/*g*/|]");`
|
|
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
|
|
f.VerifyCompletions(t, "f", &fourslash.CompletionsExpectedList{
|
|
IsIncomplete: false,
|
|
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
|
|
CommitCharacters: &DefaultCommitCharacters,
|
|
EditRange: Ignored,
|
|
},
|
|
Items: &fourslash.CompletionsExpectedItems{
|
|
Exact: []fourslash.CompletionsExpectedItem{
|
|
&lsproto.CompletionItem{
|
|
Label: "a",
|
|
TextEdit: &lsproto.TextEditOrInsertReplaceEdit{
|
|
TextEdit: &lsproto.TextEdit{
|
|
NewText: "a",
|
|
Range: f.Ranges()[0].LSRange,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
f.VerifyCompletions(t, "g", &fourslash.CompletionsExpectedList{
|
|
IsIncomplete: false,
|
|
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
|
|
CommitCharacters: &DefaultCommitCharacters,
|
|
EditRange: Ignored,
|
|
},
|
|
Items: &fourslash.CompletionsExpectedItems{
|
|
Exact: []fourslash.CompletionsExpectedItem{
|
|
&lsproto.CompletionItem{
|
|
Label: "a",
|
|
TextEdit: &lsproto.TextEditOrInsertReplaceEdit{
|
|
TextEdit: &lsproto.TextEdit{
|
|
NewText: "a",
|
|
Range: f.Ranges()[1].LSRange,
|
|
},
|
|
},
|
|
},
|
|
&lsproto.CompletionItem{
|
|
Label: "b",
|
|
TextEdit: &lsproto.TextEditOrInsertReplaceEdit{
|
|
TextEdit: &lsproto.TextEdit{
|
|
NewText: "b",
|
|
Range: f.Ranges()[1].LSRange,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
}
|