1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-11-25 15:42:01 +02:00

added Context JSVM bind

This commit is contained in:
Gani Georgiev
2024-10-03 13:27:08 +03:00
parent f9d6549469
commit 9797e6c48f
4 changed files with 3144 additions and 3045 deletions

View File

@@ -43,7 +43,7 @@ func TestBaseBindsCount(t *testing.T) {
vm := goja.New()
baseBinds(vm)
testBindsCount(vm, "this", 34, t)
testBindsCount(vm, "this", 35, t)
}
func TestBaseBindsSleep(t *testing.T) {
@@ -138,6 +138,30 @@ func TestBaseBindsUnmarshal(t *testing.T) {
}
}
func TestBaseBindsContext(t *testing.T) {
vm := goja.New()
baseBinds(vm)
_, err := vm.RunString(`
const base = new Context(null, "a", 123);
const sub = new Context(base, "b", 456);
const scenarios = [
{key: "a", expected: 123},
{key: "b", expected: 456},
];
for (let s of scenarios) {
if (sub.value(s.key) != s.expected) {
throw new("Expected " +s.key + " value " + s.expected + ", got " + sub.value(s.key));
}
}
`)
if err != nil {
t.Fatal(err)
}
}
func TestBaseBindsCookie(t *testing.T) {
vm := goja.New()
baseBinds(vm)