test(verifier): one spec bundler instead of four

The four differed only in which rows of the alias map they omitted, and esbuild
applies an alias only on an actual import, so the omissions were not a
difference. One bundleSpec carries what genuinely varied: an inline spec or a
path on disk, and an optional runtime entry to swap for the shipped one.
This commit is contained in:
pj committed 2026-08-22 21:20:40 +05:30
1 parent 22296c5316
commit 5a0439d394
4 files changed
+70 -120

No files matched your search

+6 -39
View File
@@ -2,48 +2,15 @@ package verifier
import (
"encoding/json"
"path/filepath"
"testing"
"github.com/priyanshujain/sanderling/internal/bundler"
"github.com/priyanshujain/sanderling/internal/hierarchy"
"github.com/priyanshujain/sanderling/internal/ltl"
)
// bundleIntegrationSpec bundles testdata/integration_spec.ts via the real
// @sanderling/spec API so the integration test exercises the same path the CLI
// uses, with no reference to any specific example app.
func bundleIntegrationSpec(t *testing.T) string {
t.Helper()
specPath, err := filepath.Abs("testdata/integration_spec.ts")
if err != nil {
t.Fatal(err)
}
apiPath, err := filepath.Abs("../../pkg/spec/src/index.ts")
if err != nil {
t.Fatal(err)
}
runtimePath, err := filepath.Abs("../../pkg/spec/src/goja-runtime.ts")
if err != nil {
t.Fatal(err)
}
defaultsPath, err := filepath.Abs("../../pkg/spec/src/defaults/properties.ts")
if err != nil {
t.Fatal(err)
}
bundle, err := bundler.Bundle(bundler.Options{
EntryFile: specPath,
RuntimeFile: runtimePath,
Aliases: map[string]string{
"@sanderling/spec": apiPath,
"@sanderling/spec/defaults/properties": defaultsPath,
},
})
if err != nil {
t.Fatal(err)
}
return string(bundle.JavaScript)
}
// The integration spec carries no reference to any specific example app, so
// bundling it exercises the CLI's path over a neutral subject.
var integrationSpec = bundleOptions{SpecFile: "testdata/integration_spec.ts"}
func listSnapshots() Snapshots {
return Snapshots{
@@ -66,7 +33,7 @@ func formSnapshots() Snapshots {
// primary button when both are present in the hierarchy.
func TestIntegrationSpecFiresInputActions(t *testing.T) {
v := newVerifier(t)
if err := v.Load(bundleIntegrationSpec(t)); err != nil {
if err := v.Load(bundleSpec(t, integrationSpec)); err != nil {
t.Fatal(err)
}
@@ -106,7 +73,7 @@ func TestIntegrationSpecFiresInputActions(t *testing.T) {
// for liveness properties that haven't had time to resolve yet.
func TestIntegrationSpecPropertiesEvaluate(t *testing.T) {
v := newVerifier(t)
if err := v.Load(bundleIntegrationSpec(t)); err != nil {
if err := v.Load(bundleSpec(t, integrationSpec)); err != nil {
t.Fatal(err)
}
@@ -163,7 +130,7 @@ func TestIntegrationSpecActionsFireOnEachRoute(t *testing.T) {
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
v := newVerifier(t)
if err := v.Load(bundleIntegrationSpec(t)); err != nil {
if err := v.Load(bundleSpec(t, integrationSpec)); err != nil {
t.Fatal(err)
}
tree, err := hierarchy.Parse(tc.hierarchy)