No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

testshared.d.ts 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { FirebaseApp } from '@firebase/app-types';
  2. import { StorageError } from '../../src/implementation/error';
  3. import { Headers, Connection, ConnectionType } from '../../src/implementation/connection';
  4. import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
  5. import { Provider } from '@firebase/component';
  6. import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
  7. import { FirebaseStorageImpl } from '../../src/service';
  8. import { Metadata } from '../../src/metadata';
  9. export declare const authToken = "totally-legit-auth-token";
  10. export declare const appCheckToken = "totally-shady-token";
  11. export declare const bucket = "mybucket";
  12. export declare const fakeApp: FirebaseApp;
  13. export declare const fakeAuthProvider: Provider<"auth-internal">;
  14. export declare const emptyAuthProvider: Provider<"auth-internal">;
  15. export declare const fakeAppCheckTokenProvider: Provider<"app-check-internal">;
  16. export declare function makeFakeApp(bucketArg?: string): FirebaseApp;
  17. export declare function makeFakeAuthProvider(token: {
  18. accessToken: string;
  19. }): Provider<FirebaseAuthInternalName>;
  20. export declare function makeFakeAppCheckProvider(tokenResult: {
  21. token: string;
  22. }): Provider<AppCheckInternalComponentName>;
  23. /**
  24. * Returns something that looks like an fbs.XhrIo with the given headers
  25. * and status.
  26. */
  27. export declare function fakeXhrIo<I extends ConnectionType = string>(headers: Headers, status?: number): Connection<I>;
  28. /**
  29. * Binds ignoring types. Used to test calls involving improper arguments.
  30. */
  31. export declare function bind(f: Function, ctx: any, ...args: any[]): () => void;
  32. export declare function assertThrows(f: () => void, code: string): StorageError;
  33. export declare function assertUint8ArrayEquals(arr1: Uint8Array, arr2: Uint8Array): void;
  34. export declare function assertObjectIncludes(included: {
  35. [name: string]: any;
  36. }, obj: {
  37. [name: string]: any;
  38. }): void;
  39. interface Response {
  40. status: number;
  41. body: string;
  42. headers: Headers;
  43. }
  44. export declare type RequestHandler = (url: string, method: string, body?: ArrayBufferView | Blob | string | null, headers?: Headers) => Response;
  45. export declare function storageServiceWithHandler(handler: RequestHandler, shouldResponseCb?: () => boolean): FirebaseStorageImpl;
  46. export declare function fakeServerHandler(fakeMetadata?: Partial<Metadata>): RequestHandler;
  47. /**
  48. * Responds with a 503 for finalize.
  49. * @param fakeMetadata metadata to respond with for finalize
  50. * @returns a handler for requests
  51. */
  52. export declare function fake503ForFinalizeServerHandler(fakeMetadata?: Partial<Metadata>): RequestHandler;
  53. /**
  54. * Responds with a 503 for upload.
  55. * @param fakeMetadata metadata to respond with for query
  56. * @returns a handler for requests
  57. */
  58. export declare function fake503ForUploadServerHandler(fakeMetadata?: Partial<Metadata>, cb?: () => void): RequestHandler;
  59. export declare function fakeOneShot503ServerHandler(fakeMetadata?: Partial<Metadata>): RequestHandler;
  60. export {};