-
Notifications
You must be signed in to change notification settings - Fork 2
/
mod.test.ts
50 lines (47 loc) · 1.39 KB
/
mod.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2022-2024 Kitson P. Kelly. All rights reserved. MIT License
import { assertEquals } from "jsr:@std/assert@0.223/assert-equals";
import { objectToEntity } from "./mod.ts";
Deno.test({
name: "objectToEntity - simple map",
fn() {
const d = new Date();
const actual = objectToEntity({
s: "s",
a: ["s", "t"],
e: { s: "s" },
f: 3.1415926,
g: { longitude: 1, latitude: -1 },
i: 9223372036854775807n,
k: { path: [{ id: "a", kind: "A" }] },
n: 1,
o: null,
b: true,
d,
t: {
toJSON() {
return "t";
},
},
u: new Uint8Array([1, 2, 3, 4]),
});
assertEquals(actual, {
properties: {
s: { stringValue: "s" },
a: {
arrayValue: { values: [{ stringValue: "s" }, { stringValue: "t" }] },
},
e: { entityValue: { properties: { s: { stringValue: "s" } } } },
f: { doubleValue: 3.1415926 },
g: { geoPointValue: { latitude: -1, longitude: 1 } },
i: { integerValue: "9223372036854775807" },
k: { keyValue: { path: [{ id: "a", kind: "A" }] } },
n: { integerValue: "1" },
o: { nullValue: "NULL_VALUE" },
b: { booleanValue: true },
d: { timestampValue: d.toISOString() },
t: { stringValue: "t" },
u: { blobValue: "AQIDBA==", excludeFromIndexes: true },
},
});
},
});