MCPcopy
hub / github.com/pocketbase/pocketbase / TestBindCoreValidationError

Function TestBindCoreValidationError

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

Source from the content-addressed store, hash-verified

651}
652
653func TestBindCoreValidationError(t *testing.T) {
654 vm := goja.New()
655 BindCore(vm)
656
657 scenarios := []struct {
658 js string
659 expectCode string
660 expectMessage string
661 }{
662 {
663 `new ValidationError()`,
664 "",
665 "",
666 },
667 {
668 `new ValidationError("test_code")`,
669 "test_code",
670 "",
671 },
672 {
673 `new ValidationError("test_code", "test_message")`,
674 "test_code",
675 "test_message",
676 },
677 }
678
679 for _, s := range scenarios {
680 v, err := vm.RunString(s.js)
681 if err != nil {
682 t.Fatal(err)
683 }
684
685 m, ok := v.Export().(validation.Error)
686 if !ok {
687 t.Fatalf("[%s] Expected validation.Error, got %v", s.js, m)
688 }
689
690 if m.Code() != s.expectCode {
691 t.Fatalf("[%s] Expected code %q, got %q", s.js, s.expectCode, m.Code())
692 }
693
694 if m.Message() != s.expectMessage {
695 t.Fatalf("[%s] Expected message %q, got %q", s.js, s.expectMessage, m.Message())
696 }
697 }
698}
699
700func TestBindDbx(t *testing.T) {
701 app, _ := tests.NewTestApp()

Callers

nothing calls this directly

Calls 2

BindCoreFunction · 0.85
CodeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…