mockbase
Version:
Firebase v7+ mock.
32 lines (31 loc) • 2.32 kB
TypeScript
import * as firebase from "firebase";
import { Observer } from "../util";
import { MockCollectionReference } from "./collection-reference";
import { MockDocumentSnapshot } from "./document-snapshot";
import { MockFirestore } from "./firestore";
export declare const SNAPSHOT_NEXT_EVENT = "snapshot:next";
export declare const SNAPSHOT_ERROR_EVENT = "snapshot:error";
export declare class MockDocumentReference<T = firebase.firestore.DocumentData> implements firebase.firestore.DocumentReference<T> {
readonly firestore: MockFirestore;
readonly id: string;
readonly parent: MockCollectionReference<T>;
readonly converter: firebase.firestore.FirestoreDataConverter<T>;
private readonly emitEvents;
get path(): string;
private get emitter();
private get currentData();
constructor(firestore: MockFirestore, id: string, parent: MockCollectionReference<T>, converter: firebase.firestore.FirestoreDataConverter<T>, emitEvents?: boolean);
emitChange(): Promise<void>;
collection(collectionPath: string): firebase.firestore.CollectionReference<firebase.firestore.DocumentData>;
isEqual(other: firebase.firestore.DocumentReference<T>): boolean;
set(data: T, options?: firebase.firestore.SetOptions | undefined): Promise<void>;
update(data: firebase.firestore.UpdateData): Promise<void>;
update(field: string | firebase.firestore.FieldPath, value: any, ...moreFieldsAndValues: any[]): Promise<void>;
delete(): Promise<void>;
get(options?: firebase.firestore.GetOptions): Promise<MockDocumentSnapshot<T>>;
onSnapshot(observer: Observer<firebase.firestore.DocumentSnapshot<T>>): () => void;
onSnapshot(options: firebase.firestore.SnapshotListenOptions, observer: Observer<firebase.firestore.DocumentSnapshot<T>>): () => void;
onSnapshot(onNext: (snapshot: firebase.firestore.DocumentSnapshot<T>) => void, onError?: ((error: Error) => void) | undefined, onCompletion?: (() => void) | undefined): () => void;
onSnapshot(options: firebase.firestore.SnapshotListenOptions, onNext: (snapshot: firebase.firestore.DocumentSnapshot<T>) => void, onError?: ((error: Error) => void) | undefined, onCompletion?: (() => void) | undefined): () => void;
withConverter<U>(converter: firebase.firestore.FirestoreDataConverter<U>): MockDocumentReference<U>;
}