MCPcopy Index your code
hub / github.com/pocketbase/pocketbase / TestBindCoreToString

Function TestBindCoreToString

plugins/jsvm/binds_test.go:89–121  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

87}
88
89func TestBindCoreToString(t *testing.T) {
90 vm := goja.New()
91 BindCore(vm)
92 vm.Set("scenarios", []struct {
93 Name string
94 Value any
95 Expected string
96 }{
97 {"null", nil, ""},
98 {"string", "test", "test"},
99 {"number", -12.4, "-12.4"},
100 {"bool", true, "true"},
101 {"arr", []int{1, 2, 3}, `[1,2,3]`},
102 {"obj", map[string]any{"test": 123}, `{"test":123}`},
103 {"reader", strings.NewReader("test"), "test"},
104 {"struct", struct {
105 Name string
106 private string
107 }{Name: "123", private: "456"}, `{"Name":"123"}`},
108 })
109
110 _, err := vm.RunString(`
111 for (let s of scenarios) {
112 let str = toString(s.value)
113 if (str != s.expected) {
114 throw new Error('[' + s.name + '] Expected string ' + s.expected + ', got ' + str);
115 }
116 }
117 `)
118 if err != nil {
119 t.Fatal(err)
120 }
121}
122
123func TestBindCoreToBytes(t *testing.T) {
124 vm := goja.New()

Callers

nothing calls this directly

Calls 3

BindCoreFunction · 0.85
NewReaderMethod · 0.80
SetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…