mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
27 lines
989 B
Go
27 lines
989 B
Go
package incremental
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/microsoft/typescript-go/internal/ast"
|
|
"github.com/microsoft/typescript-go/internal/core"
|
|
"github.com/microsoft/typescript-go/internal/diagnostics"
|
|
"github.com/microsoft/typescript-go/internal/locale"
|
|
"github.com/microsoft/typescript-go/internal/parser"
|
|
"gotest.tools/v3/assert"
|
|
)
|
|
|
|
func TestExternalDiagnosticBuildInfoRoundTrip(t *testing.T) {
|
|
t.Parallel()
|
|
file := parser.ParseSourceFile(ast.SourceFileParseOptions{FileName: "/app.vue", Path: "/app.vue"}, "", core.ScriptKindTS)
|
|
diagnostic := ast.NewExternalDiagnostic(file, core.NewTextRange(1, 2), "vue", diagnostics.CategoryWarning, 1001, "mapper warning")
|
|
|
|
serialized := astDiagToBuildInfoDiag(diagnostic)
|
|
assert.Equal(t, serialized.source, "vue")
|
|
assert.Equal(t, serialized.messageText, "mapper warning")
|
|
|
|
restored := serialized.toDiagnostic(nil, file)
|
|
assert.Equal(t, restored.Source(), "vue")
|
|
assert.Equal(t, restored.Localize(locale.Default), "mapper warning")
|
|
}
|