MCPcopy Create free account
hub / github.com/pocketbase/pocketbase / TestBindCoreCollection

Function TestBindCoreCollection

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

Source from the content-addressed store, hash-verified

309}
310
311func TestBindCoreCollection(t *testing.T) {
312 vm := goja.New()
313 BindCore(vm)
314
315 v, err := vm.RunString(`new Collection({ name: "test", createRule: "@request.auth.id != ''", fields: [{name: "title", "type": "text"}] })`)
316 if err != nil {
317 t.Fatal(err)
318 }
319
320 m, ok := v.Export().(*core.Collection)
321 if !ok {
322 t.Fatalf("Expected core.Collection, got %v", m)
323 }
324
325 if m.Name != "test" {
326 t.Fatalf("Expected collection with name %q, got %q", "test", m.Name)
327 }
328
329 expectedRule := "@request.auth.id != ''"
330 if m.CreateRule == nil || *m.CreateRule != expectedRule {
331 t.Fatalf("Expected create rule %q, got %v", "@request.auth.id != ''", m.CreateRule)
332 }
333
334 if f := m.Fields.GetByName("title"); f == nil {
335 t.Fatalf("Expected fields to be set, got %v", m.Fields)
336 }
337}
338
339func TestBindCoreFieldsList(t *testing.T) {
340 vm := goja.New()

Callers

nothing calls this directly

Calls 2

BindCoreFunction · 0.85
GetByNameMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…