mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package fourslash_test
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/microsoft/typescript-go/internal/fourslash"
|
|
"github.com/microsoft/typescript-go/internal/testutil/contentmappertest"
|
|
)
|
|
|
|
func newContentMapperFourslash(t *testing.T, content, mapper string, extensions ...string) (*fourslash.FourslashTest, func()) {
|
|
t.Helper()
|
|
quotedExtensions := make([]string, len(extensions))
|
|
for i, extension := range extensions {
|
|
quotedExtensions[i] = strconv.Quote(extension)
|
|
}
|
|
content = `// @Filename: /tsconfig.json
|
|
{
|
|
"compilerOptions": {
|
|
"target": "es2020",
|
|
"module": "esnext",
|
|
"moduleResolution": "bundler",
|
|
"strict": true
|
|
},
|
|
"contentMappers": [
|
|
{ "package": "mapper", "extensions": [` + strings.Join(quotedExtensions, ", ") + `] }
|
|
]
|
|
}
|
|
|
|
// @Filename: /node_modules/mapper/package.json
|
|
` + contentmappertest.PackageJSON(mapper) + `
|
|
|
|
` + content
|
|
return fourslash.NewFourslashWithOptions(t, content, &fourslash.FourslashOptions{
|
|
ContentMapperSpawner: contentmappertest.NewSpawner(),
|
|
RunExternalCode: true,
|
|
})
|
|
}
|