Created
January 1, 2023 23:12
-
-
Save pocha/cd13f511180d12844b6cb93b3f74681e to your computer and use it in GitHub Desktop.
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
import { initializeTestEnvironment } from "@firebase/rules-unit-testing" | |
import { setLogLevel } from "firebase/firestore" | |
const FIREBASE_PROJECT_ID = "xxxx" | |
export const USER_COLLECTION = "users-main" | |
export const APPLICATION_COLLECTION = "applications" | |
export const ASHISH_ID = "xxxx" | |
export const BETTS_ID = "xxxx" | |
export const ZUKA_ID = "xxxx" | |
let rulesTestEnv | |
export const initialize_firestore_db = async () => { | |
if (!rulesTestEnv) { | |
setLogLevel("silent") // hiding logs that show up when writes fail | |
rulesTestEnv = await initializeTestEnvironment({ | |
projectId: FIREBASE_PROJECT_ID, | |
firestore: { | |
host: "localhost", | |
port: 8080, | |
}, | |
}) | |
} | |
} | |
export const get_fresh_collection_ref = (uid, collection) => { | |
if (!uid) return rulesTestEnv.unauthenticatedContext().firestore().collection(collection) | |
return rulesTestEnv.authenticatedContext(uid).firestore().collection(collection) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment