mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
67 lines
1.8 KiB
Go
67 lines
1.8 KiB
Go
package fourslash_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/microsoft/typescript-go/internal/core"
|
|
"github.com/microsoft/typescript-go/internal/fourslash"
|
|
. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"
|
|
"github.com/microsoft/typescript-go/internal/ls/lsutil"
|
|
"github.com/microsoft/typescript-go/internal/lsp/lsproto"
|
|
"github.com/microsoft/typescript-go/internal/testutil"
|
|
)
|
|
|
|
func TestClassMemberCompletionKeepsNameFallback(t *testing.T) {
|
|
t.Parallel()
|
|
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
|
|
const content = `class B {
|
|
constructor(public value: string) {}
|
|
}
|
|
class C extends B {
|
|
/*a*/
|
|
}`
|
|
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
|
|
defer done()
|
|
|
|
f.VerifyCompletions(t, "a", &fourslash.CompletionsExpectedList{
|
|
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
|
|
CommitCharacters: &[]string{},
|
|
EditRange: Ignored,
|
|
},
|
|
Items: &fourslash.CompletionsExpectedItems{
|
|
Includes: []fourslash.CompletionsExpectedItem{
|
|
&lsproto.CompletionItem{
|
|
Label: "value",
|
|
InsertText: new("value"),
|
|
},
|
|
},
|
|
},
|
|
UserPreferences: &lsutil.UserPreferences{IncludeCompletionsWithClassMemberSnippets: core.TSTrue},
|
|
})
|
|
}
|
|
|
|
func TestImplementClassFixDoesNotAddInvalidOverride(t *testing.T) {
|
|
t.Parallel()
|
|
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
|
|
const content = `// @noImplicitOverride: true
|
|
class B {
|
|
method() {}
|
|
}
|
|
class C implements B {[| |]}`
|
|
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
|
|
defer done()
|
|
|
|
f.VerifyCodeFix(t, fourslash.VerifyCodeFixOptions{
|
|
Description: "Implement interface 'B'",
|
|
NewFileContent: `class B {
|
|
method() {}
|
|
}
|
|
class C implements B {
|
|
method(): void {
|
|
throw new Error("Method not implemented.");
|
|
}
|
|
}`,
|
|
Index: 0,
|
|
})
|
|
}
|