-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add json serialization support for neo4j sdk types (#699)
- Loading branch information
Showing
6 changed files
with
127 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2024 Hypermode Inc. | ||
* Licensed under the terms of the Apache License, Version 2.0 | ||
* See the LICENSE file that accompanied this code for further details. | ||
* | ||
* SPDX-FileCopyrightText: 2024 Hypermode Inc. <[email protected]> | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { JSON } from "json-as"; | ||
import { expect, it, run } from "as-test"; | ||
import { neo4j } from ".."; | ||
|
||
it("should stringify a simple record", () => { | ||
const record = new neo4j.Record(); | ||
record.Keys = ["name"]; | ||
record.Values = ['"Alice"']; | ||
|
||
expect(JSON.stringify(record)).toBe('{"name":"Alice"}'); | ||
}); | ||
|
||
it("should stringify different types of record values", () => { | ||
const record = new neo4j.Record(); | ||
record.Keys = ["name", "age", "friends"]; | ||
record.Values = ['"Alice"', '"42"', '["Bob","Peter","Anna"]']; | ||
|
||
expect(JSON.stringify(record)).toBe( | ||
'{"name":"Alice","age":"42","friends":["Bob","Peter","Anna"]}', | ||
); | ||
}); | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright 2024 Hypermode Inc. | ||
* Licensed under the terms of the Apache License, Version 2.0 | ||
* See the LICENSE file that accompanied this code for further details. | ||
* | ||
* SPDX-FileCopyrightText: 2024 Hypermode Inc. <[email protected]> | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { readFileSync } from "fs"; | ||
import { instantiate } from "../build/neo4j.spec.js"; | ||
const binary = readFileSync("./build/neo4j.spec.wasm"); | ||
const module = new WebAssembly.Module(binary); | ||
instantiate(module, { | ||
env: {}, | ||
modus_models: {}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters