replaced DynamicList with a more generic (model) helper to allow creating pointer slice of any type

This commit is contained in:
Gani Georgiev
2023-06-25 20:19:01 +03:00
parent 39accdba58
commit 051b3702b0
4 changed files with 5315 additions and 5248 deletions

View File

@@ -91,7 +91,7 @@ func TestBaseBindsCollection(t *testing.T) {
vm := goja.New()
baseBinds(vm)
v, err := vm.RunString(`new Collection({ name: "test", schema: [{name: "title", "type": "text"}] })`)
v, err := vm.RunString(`new Collection({ name: "test", createRule: "@request.auth.id != ''", schema: [{name: "title", "type": "text"}] })`)
if err != nil {
t.Fatal(err)
}
@@ -105,6 +105,11 @@ func TestBaseBindsCollection(t *testing.T) {
t.Fatalf("Expected collection with name %q, got %q", "test", m.Name)
}
expectedRule := "@request.auth.id != ''"
if m.CreateRule == nil || *m.CreateRule != expectedRule {
t.Fatalf("Expected create rule %q, got %v", "@request.auth.id != ''", m.CreateRule)
}
if f := m.Schema.GetFieldByName("title"); f == nil {
t.Fatalf("Expected schema to be set, got %v", m.Schema)
}
@@ -796,7 +801,7 @@ func TestLoadingDynamicModel(t *testing.T) {
}
}
func TestLoadingDynamicList(t *testing.T) {
func TestLoadingArrayOf(t *testing.T) {
app, _ := tests.NewTestApp()
defer app.Cleanup()
@@ -806,10 +811,10 @@ func TestLoadingDynamicList(t *testing.T) {
vm.Set("$app", app)
_, err := vm.RunString(`
let result = new DynamicList({
let result = $arrayOf(new DynamicModel({
id: "",
text: "",
})
}))
$app.dao().db()
.select("id", "text")