MCPcopy
hub / github.com/pocketbase/pocketbase / TestLoadingArrayOf

Function TestLoadingArrayOf

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

Source from the content-addressed store, hash-verified

1346}
1347
1348func TestLoadingArrayOf(t *testing.T) {
1349 app, _ := tests.NewTestApp()
1350 defer app.Cleanup()
1351
1352 vm := goja.New()
1353 BindCore(vm)
1354 BindDbx(vm)
1355 vm.Set("$app", app)
1356
1357 _, err := vm.RunString(`
1358 let result = arrayOf(new DynamicModel({
1359 id: "",
1360 text: "",
1361 }))
1362
1363 $app.db()
1364 .select("id", "text")
1365 .from("demo1")
1366 .where($dbx.exp("id='84nmscqy84lsi1t' OR id='al1h9ijdeojtsjy'"))
1367 .limit(2)
1368 .orderBy("text ASC")
1369 .all(result)
1370
1371 if (result.length != 2) {
1372 throw new Error('Expected 2 list items, got ' + result.length);
1373 }
1374
1375 if (result[0].id != "84nmscqy84lsi1t") {
1376 throw new Error('Expected 0.id "84nmscqy84lsi1t", got ' + result[0].id);
1377 }
1378 if (result[0].text != "test") {
1379 throw new Error('Expected 0.text "test", got ' + result[0].text);
1380 }
1381
1382 if (result[1].id != "al1h9ijdeojtsjy") {
1383 throw new Error('Expected 1.id "al1h9ijdeojtsjy", got ' + result[1].id);
1384 }
1385 if (result[1].text != "test2") {
1386 throw new Error('Expected 1.text "test2", got ' + result[1].text);
1387 }
1388 `)
1389 if err != nil {
1390 t.Fatal(err)
1391 }
1392}
1393
1394func TestBindHTTPCount(t *testing.T) {
1395 app, _ := tests.NewTestApp()

Callers

nothing calls this directly

Calls 5

CleanupMethod · 0.95
NewTestAppFunction · 0.92
BindCoreFunction · 0.85
BindDbxFunction · 0.85
SetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…