Skip to content

Commit

Permalink
add missing exports
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mendez committed Jun 27, 2021
1 parent f74a147 commit 0569b14
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 22 deletions.
50 changes: 32 additions & 18 deletions firestore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Deno.test({
});

Deno.test({
name: "firestore should pass in token and fetch",
name: "firestore should pass in token and fetch document",
fn: async () => {
setToken("");
const d = await firestore.getDocument({ ...body, authorization: t });
Expand All @@ -70,6 +70,23 @@ Deno.test({
},
});

Deno.test({
name: "firestore should get token from service account",
fn: async () => {
if (Boolean(Deno.env.get("CI")) === true) {
const d = await setTokenFromEmailPassword();
const v = d.slice(0, 4);
assertEquals(v, "eyJh");
} else {
const d = await setTokenFromServiceAccount();
const v = d.slice(0, 4);
assertEquals(v, "ya29");
}
},
sanitizeResources: false,
sanitizeOps: false,
});

Deno.test({
name: "firestore should get list from collection",
fn: async () => {
Expand All @@ -83,25 +100,22 @@ Deno.test({
fn: async () => {
const d = await firestore.updateDocument({
...body,
update: { lastname: { stringValue: "Jeff" } },
value: { lastname: { stringValue: "Jeff" } },
});
assertEquals(d.fields.lastname.stringValue, "Jeff");
},
});

Deno.test({
name: "firestore should get token from service account",
fn: async () => {
if (Boolean(Deno.env.get("CI")) === true) {
const d = await setTokenFromEmailPassword();
const v = d.slice(0, 4);
assertEquals(v, "eyJh");
} else {
const d = await setTokenFromServiceAccount();
const v = d.slice(0, 4);
assertEquals(v, "ya29");
}
},
sanitizeResources: false,
sanitizeOps: false,
});
// Deno.test({
// name: "firestore should create item from collection",
// fn: async () => {
// const d = await firestore.createDocument({
// ...body,
// value: {
// firstname: { stringValue: "Jeff" },
// lastname: { stringValue: "Jeff" },
// },
// });
// assertEquals(d.fields.lastname.stringValue, "Jeff");
// },
// });
6 changes: 3 additions & 3 deletions firestore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { FetchRequest } from "./client.ts";
interface FireRequest {
collection?: string;
id?: string;
update?: object;
value?: object;
}

type RequestInterface = FireRequest & Partial<FetchRequest>;
Expand Down Expand Up @@ -56,7 +56,7 @@ const firestore = {
authorization,
collection,
id,
update,
value,
}: RequestInterface) => {
validateRequest({ collection, id });

Expand All @@ -66,7 +66,7 @@ const firestore = {
authorization,
reqBody: {
name: id,
fields: update,
fields: value,
},
});
},
Expand Down
9 changes: 8 additions & 1 deletion mod.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
export { firestore } from "./firestore.ts";
export { setToken } from "./config.ts";
export {
config,
setDatabase,
setProjectID,
setToken,
setTokenFromServiceAccount,
setTokenFromEmailPassword,
} from "./config.ts";

0 comments on commit 0569b14

Please sign in to comment.