kittenipc/kitcom/internal/tsgo/testrunner/test_case_parser_test.go
2025-10-15 10:12:44 +03:00

42 lines
937 B
Go

package testrunner
import (
"testing"
"github.com/google/go-cmp/cmp"
"gotest.tools/v3/assert"
)
func TestMakeUnitsFromTest(t *testing.T) {
t.Parallel()
code := `// @strict: true
// @noEmit: true
// @filename: firstFile.ts
function foo() { return "a"; }
// normal comment
// @filename: secondFile.ts
// some other comment
function bar() { return "b"; }`
testUnit1 := &testUnit{
content: `function foo() { return "a"; }
// normal comment`,
name: "firstFile.ts",
}
testUnit2 := &testUnit{
content: `// some other comment
function bar() { return "b"; }`,
name: "secondFile.ts",
}
testContent := testCaseContent{
testUnitData: []*testUnit{testUnit1, testUnit2},
tsConfig: nil,
tsConfigFileUnitData: nil,
symlinks: make(map[string]string),
}
assert.DeepEqual(
t,
makeUnitsFromTest(code, "simpleTest.ts"),
testContent,
cmp.AllowUnexported(testCaseContent{}, testUnit{}))
}