Files
zip/runtime/esbuild_test.go
T
zeekay c581e0af7b feat: zip canonical home — the ZAP-native web framework, consolidated
zip is shared protocol infra (the fiber-over-ZAP web framework used by every
Lux/Hanzo/Zoo Go binary — nodes, gateway, cloud, iam, kms, o11y, ai, …), so its
home is the ZAP protocol family (zap-proto/{go,http,zapd,zip}), NOT any one org's
brand namespace. This consolidates the rich framework (formerly hanzoai/zip v0.5.0
— Ctx/Handler/Errorf/Err*/HTTPError, typed handlers, middleware, runtime/extension
loading, openapi, validate, zaprpc) with the real ZAP transport (ListenZAP/
ListenHTTP/Serve over zap-proto/http) into ONE canonical module.

Module path github.com/hanzoai/zip -> github.com/zap-proto/zip. Code identical to
hanzoai/zip v0.5.0; promoted to v1.0.0 as the stable shared-infra framework. The
prior hanzoai/zip lineage is retired — one home, one import path, one way.

Verified: go build/vet/test ./... green; the ZAP round-trip integration test serves
/v1/health over the real ZAP transport (200 + handler JSON).
2026-07-01 23:08:35 -07:00

42 lines
1.0 KiB
Go

package runtime
import (
"strings"
"testing"
)
func TestTranspileToES5_RunsInGoja(t *testing.T) {
// TS with arrow fn + spread + type annotation. esbuild lowers it to
// goja-runnable JS and strips the types.
src := []byte(`
const add = (...xs: number[]): number => xs.reduce((a, b) => a + b, 0);
module.exports = { total: add(1, 2, 3, 4) };
`)
out, err := TranspileToES5(src, ESOptions{Loader: "ts", Sourcefile: "add.ts"})
if err != nil {
t.Fatal(err)
}
if strings.Contains(string(out), ": number") {
t.Fatalf("types not stripped: %s", out)
}
rt, _ := NewJSRuntime(JSOptions{PoolSize: 1})
if err := rt.LoadModule("add", string(out)); err != nil {
t.Fatal(err)
}
v, err := rt.Eval(`require("add").total`)
if err != nil {
t.Fatal(err)
}
if got := v.(int64); got != 10 {
t.Fatalf("total = %d, want 10", got)
}
}
func TestTranspileError(t *testing.T) {
_, err := TranspileToES5([]byte("const x = ;"), ESOptions{Loader: "ts"})
if err == nil {
t.Fatal("expected syntax error, got nil")
}
}