UNPKG

mockbase

Version:
57 lines (56 loc) 3.57 kB
import * as firebase from "firebase"; import { EventEmitter, Observer } from "../util"; import { MockQueryDocumentSnapshot } from "./document-snapshot"; import { MockFirestore } from "./firestore"; import { MockQuerySnapshot } from "./query-snapshot"; declare type QueryFilter = (doc: MockQueryDocumentSnapshot, index: number, allDocs: MockQueryDocumentSnapshot[]) => boolean; declare type Ordering = { fieldPath: string; direction: "asc" | "desc"; }; export declare const QUERY_SNAPSHOT_NEXT_EVENT = "snapshot:next"; export declare const QUERY_SNAPSHOT_ERROR_EVENT = "snapshot:error"; export declare const QUERY_SNAPSHOT_COMPLETE_EVENT = "snapshot:complete"; export declare class MockQuery<T = firebase.firestore.DocumentData> implements firebase.firestore.Query<T> { readonly firestore: MockFirestore; readonly path: string; converter: firebase.firestore.FirestoreDataConverter<T>; protected docsStartLimit?: number; protected docsEndLimit?: number; protected filters: Record<string, QueryFilter>; protected ordering?: Ordering; private noInitialSnapshot; protected get emitter(): EventEmitter; constructor(firestore: MockFirestore, path: string, converter: firebase.firestore.FirestoreDataConverter<T>); emitChange(): Promise<void>; setNoInitialSnapshot(): this; protected clone(): MockQuery<T>; where(fieldPath: string | firebase.firestore.FieldPath, opStr: firebase.firestore.WhereFilterOp, value: any): firebase.firestore.Query<T>; orderBy(fieldPath: string | firebase.firestore.FieldPath, direction?: "desc" | "asc"): firebase.firestore.Query<T>; limit(limit: number): firebase.firestore.Query<T>; limitToLast(limit: number): firebase.firestore.Query<T>; startAt(snapshot: firebase.firestore.DocumentSnapshot<any>): firebase.firestore.Query<T>; startAt(...fieldValues: any[]): firebase.firestore.Query<T>; startAfter(snapshot: firebase.firestore.DocumentSnapshot<any>): firebase.firestore.Query<T>; startAfter(...fieldValues: any[]): firebase.firestore.Query<T>; private addStartFilter; endBefore(snapshot: firebase.firestore.DocumentSnapshot<any>): firebase.firestore.Query<T>; endBefore(...fieldValues: any[]): firebase.firestore.Query<T>; endAt(snapshot: firebase.firestore.DocumentSnapshot<any>): firebase.firestore.Query<T>; endAt(...fieldValues: any[]): firebase.firestore.Query<T>; private addEndFilter; isEqual(other: firebase.firestore.Query<T>): boolean; private compareFunction; /** * Gets a list of doc keys that should be fetched by the #get() method. * Made protected so that the collection group implementation can override it. */ protected getCandidateDocKeys(): Set<string>; get(options?: firebase.firestore.GetOptions): Promise<MockQuerySnapshot<T>>; onSnapshot(observer: Observer<firebase.firestore.QuerySnapshot<T>>): () => void; onSnapshot(options: firebase.firestore.SnapshotListenOptions, observer: Observer<firebase.firestore.QuerySnapshot<T>>): () => void; onSnapshot(onNext: (snapshot: firebase.firestore.QuerySnapshot<T>) => void, onError?: ((error: Error) => void) | undefined, onCompletion?: (() => void) | undefined): () => void; onSnapshot(options: firebase.firestore.SnapshotListenOptions, onNext: (snapshot: firebase.firestore.QuerySnapshot<T>) => void, onError?: ((error: Error) => void) | undefined, onCompletion?: (() => void) | undefined): () => void; withConverter<U>(converter: firebase.firestore.FirestoreDataConverter<U>): MockQuery<U>; } export {};