mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
53 lines
1.6 KiB
Go
53 lines
1.6 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 TestImportStatementCompletionUsesNamedImport(t *testing.T) {
|
|
t.Parallel()
|
|
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
|
|
const content = `// @Filename: a.ts
|
|
export interface I {}
|
|
// @Filename: 1.ts
|
|
import * as u from "./a";
|
|
[|import I/*a*/|]`
|
|
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
|
|
defer done()
|
|
|
|
preferences := lsutil.NewDefaultUserPreferences()
|
|
preferences.IncludeCompletionsForModuleExports = core.TSFalse
|
|
preferences.IncludeCompletionsForImportStatements = core.TSTrue
|
|
f.VerifyCompletions(t, "a", &fourslash.CompletionsExpectedList{
|
|
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
|
|
CommitCharacters: &[]string{},
|
|
EditRange: Ignored,
|
|
},
|
|
Items: &fourslash.CompletionsExpectedItems{
|
|
Includes: []fourslash.CompletionsExpectedItem{
|
|
&lsproto.CompletionItem{
|
|
Label: "I",
|
|
InsertText: new(`import { I } from "./a";`),
|
|
Data: &lsproto.CompletionItemData{
|
|
AutoImport: &lsproto.AutoImportFix{ModuleSpecifier: "./a"},
|
|
},
|
|
TextEdit: &lsproto.TextEditOrInsertReplaceEdit{
|
|
TextEdit: &lsproto.TextEdit{
|
|
NewText: `import { I } from "./a";`,
|
|
Range: f.Ranges()[0].LSRange,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
UserPreferences: &preferences,
|
|
})
|
|
}
|