You've already forked pocketbase
mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-11-24 07:04:51 +02:00
[#3447] added jsvm http.Cookie binding
This commit is contained in:
@@ -46,7 +46,7 @@ func TestBaseBindsCount(t *testing.T) {
|
||||
vm := goja.New()
|
||||
baseBinds(vm)
|
||||
|
||||
testBindsCount(vm, "this", 14, t)
|
||||
testBindsCount(vm, "this", 15, t)
|
||||
}
|
||||
|
||||
func TestBaseBindsReaderToString(t *testing.T) {
|
||||
@@ -69,6 +69,38 @@ func TestBaseBindsReaderToString(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBaseBindsCookie(t *testing.T) {
|
||||
app, _ := tests.NewTestApp()
|
||||
defer app.Cleanup()
|
||||
|
||||
vm := goja.New()
|
||||
baseBinds(vm)
|
||||
|
||||
_, err := vm.RunString(`
|
||||
const cookie = new Cookie({
|
||||
name: "example_name",
|
||||
value: "example_value",
|
||||
path: "/example_path",
|
||||
domain: "example.com",
|
||||
maxAge: 10,
|
||||
secure: true,
|
||||
httpOnly: true,
|
||||
sameSite: 3,
|
||||
});
|
||||
|
||||
const result = cookie.string();
|
||||
|
||||
const expected = "example_name=example_value; Path=/example_path; Domain=example.com; Max-Age=10; HttpOnly; Secure; SameSite=Strict";
|
||||
|
||||
if (expected != result) {
|
||||
throw new("Expected \n" + expected + "\ngot\n" + result);
|
||||
}
|
||||
`)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBaseBindsRecord(t *testing.T) {
|
||||
app, _ := tests.NewTestApp()
|
||||
defer app.Cleanup()
|
||||
|
||||
Reference in New Issue
Block a user