70 lines
2.0 KiB
Go
70 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/ls"
|
|
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/lsp/lsproto"
|
|
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/testutil"
|
|
)
|
|
|
|
func TestCompletionsGenericIndexedAccess3(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
|
|
const content = `interface CustomElements {
|
|
'component-one': {
|
|
foo?: string;
|
|
},
|
|
'component-two': {
|
|
bar?: string;
|
|
}
|
|
}
|
|
|
|
interface Options<T extends keyof CustomElements> {
|
|
props: CustomElements[T];
|
|
}
|
|
|
|
declare function create<T extends keyof CustomElements>(name: T, options: Options<T>): void;
|
|
|
|
create('component-one', { props: { /*1*/ } });
|
|
create('component-two', { props: { /*2*/ } });`
|
|
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
|
|
f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{
|
|
IsIncomplete: false,
|
|
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
|
|
CommitCharacters: &DefaultCommitCharacters,
|
|
EditRange: Ignored,
|
|
},
|
|
Items: &fourslash.CompletionsExpectedItems{
|
|
Exact: []fourslash.CompletionsExpectedItem{
|
|
&lsproto.CompletionItem{
|
|
Label: "foo?",
|
|
InsertText: PtrTo("foo"),
|
|
FilterText: PtrTo("foo"),
|
|
SortText: PtrTo(string(ls.SortTextOptionalMember)),
|
|
},
|
|
},
|
|
},
|
|
})
|
|
f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{
|
|
IsIncomplete: false,
|
|
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
|
|
CommitCharacters: &DefaultCommitCharacters,
|
|
EditRange: Ignored,
|
|
},
|
|
Items: &fourslash.CompletionsExpectedItems{
|
|
Exact: []fourslash.CompletionsExpectedItem{
|
|
&lsproto.CompletionItem{
|
|
Label: "bar?",
|
|
InsertText: PtrTo("bar"),
|
|
FilterText: PtrTo("bar"),
|
|
SortText: PtrTo(string(ls.SortTextOptionalMember)),
|
|
},
|
|
},
|
|
},
|
|
})
|
|
}
|