-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.test.ts
66 lines (55 loc) · 2.02 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { assertEquals } from "@std/assert";
import { FirestoreAdminClient } from "./mod.ts";
Deno.env.set(
"FIREBASE_SERVICE_ACCOUNT",
JSON.stringify({
project_id: "test-project",
client_email: "[email protected]",
private_key: "test-private-key",
}),
);
Deno.test("FirestoreAdminClient initialization", () => {
const client = new FirestoreAdminClient();
assertEquals(typeof client, "object");
});
// Deno.test('getDocument method', async () => {
// const client = new FirestoreAdminClient()
// const mockDocument = { name: 'Test Document' }
// // Mock the fetch function
// globalThis.fetch = async () => {
// return {
// json: async () => ({ fields: { name: { stringValue: 'Test Document' } } })
// } as Response
// }
// const result = await client.getDocument('test-collection/test-document')
// assertEquals(result, mockDocument)
// })
// Deno.test('getDocumentsInCollection method', async () => {
// const client = new FirestoreAdminClient()
// const mockDocuments = [{ name: 'Document 1' }, { name: 'Document 2' }]
// // Mock the fetch function
// globalThis.fetch = async () => {
// return {
// json: async () => ({
// documents: [
// { fields: { name: { stringValue: 'Document 1' } } },
// { fields: { name: { stringValue: 'Document 2' } } }
// ]
// })
// } as Response
// }
// const result = await client.getDocumentsInCollection('test-collection')
// assertEquals(result, mockDocuments)
// })
// Deno.test('updateDocument method', async () => {
// const client = new FirestoreAdminClient()
// const mockUpdateData = { name: 'Updated Document' }
// // Mock the fetch function
// globalThis.fetch = async () => {
// return {
// json: async () => ({ fields: { name: { stringValue: 'Updated Document' } } })
// } as Response
// }
// const result = await client.updateDocument('test-collection/test-document', mockUpdateData)
// assertEquals(result.fields.name.stringValue, mockUpdateData.name)
// })