2026-05-30 14:11:56 +08:00
|
|
|
package jsmod_test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
2026-05-30 15:33:57 +08:00
|
|
|
"apigo.cc/go/jsmod"
|
2026-05-30 14:11:56 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestRegister(t *testing.T) {
|
2026-05-30 15:33:57 +08:00
|
|
|
jsmod.Register("test", map[string]any{"foo": "bar"}, "foo")
|
2026-05-30 14:11:56 +08:00
|
|
|
mods := jsmod.GetModules()
|
2026-05-30 15:33:57 +08:00
|
|
|
|
|
|
|
|
mod, ok := mods["test"]
|
|
|
|
|
if !ok {
|
|
|
|
|
t.Fatal("Module not found")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if mod.Exports["foo"] != "bar" {
|
|
|
|
|
t.Error("Export failed")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !mod.UnsafeList["foo"] {
|
|
|
|
|
t.Error("UnsafeList tracking failed")
|
2026-05-30 14:11:56 +08:00
|
|
|
}
|
|
|
|
|
}
|