Compare commits

...

3 Commits

Author SHA1 Message Date
Nikita
a2049f3565 patch 2025-03-04 15:55:12 +01:00
Nikita
f799a66c24 add test and changeset 2025-03-04 15:51:08 +01:00
Nikita
ed35e7c558 encode -> encoded 2025-03-04 15:38:42 +01:00
3 changed files with 25 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
"jazz-tools": patch
---
Fix CoMap.toJSON() with encoded fields

View File

@@ -309,7 +309,7 @@ export class CoMap extends CoValueBase implements CoValue {
const descriptor = (this._schema[tKey] ||
this._schema[ItemsSym]) as Schema;
if (descriptor == "json" || "encode" in descriptor) {
if (descriptor == "json" || "encoded" in descriptor) {
return [key, this._raw.get(key)];
} else if (isRefEncoded(descriptor)) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any

View File

@@ -119,6 +119,25 @@ describe("Simple CoMap operations", async () => {
).toThrow();
});
test("testing toJSON on a CoMap with a Date field", () => {
const map = TestMap.create(
{
color: "red",
_height: 10,
birthday: new Date(),
},
{ owner: me },
);
expect(map.toJSON()).toMatchObject({
color: "red",
_height: 10,
birthday: expect.any(String),
_type: "CoMap",
id: expect.any(String),
});
});
test("setting optional date as undefined should not throw", () => {
const map = TestMap.create(
{