|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright 2020 Google LLC |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +import * as firebase from 'firebase'; |
| 19 | + |
| 20 | +// This file replaces "packages/firestore/test/integration/util/firebase_export" |
| 21 | +// and depends on the minified sources. |
| 22 | + |
| 23 | +let appCount = 0; |
| 24 | + |
| 25 | +export function newTestFirestore( |
| 26 | + projectId: string, |
| 27 | + nameOrApp?: string | firebase.app.App, |
| 28 | + settings?: firebase.firestore.Settings |
| 29 | +): firebase.firestore.Firestore { |
| 30 | + if (nameOrApp === undefined) { |
| 31 | + nameOrApp = 'test-app-' + appCount++; |
| 32 | + } |
| 33 | + const app = |
| 34 | + typeof nameOrApp === 'string' |
| 35 | + ? firebase.initializeApp({ apiKey: 'fake-api-key', projectId }, nameOrApp) |
| 36 | + : nameOrApp; |
| 37 | + |
| 38 | + const firestore = firebase.firestore(app); |
| 39 | + if (settings) { |
| 40 | + firestore.settings(settings); |
| 41 | + } |
| 42 | + return firestore; |
| 43 | +} |
| 44 | + |
| 45 | +export function usesFunctionalApi(): false { |
| 46 | + return false; |
| 47 | +} |
| 48 | + |
| 49 | +const Firestore = firebase.firestore.Firestore; |
| 50 | +const FieldPath = firebase.firestore.FieldPath; |
| 51 | +const Timestamp = firebase.firestore.Timestamp; |
| 52 | +const GeoPoint = firebase.firestore.GeoPoint; |
| 53 | +const FieldValue = firebase.firestore.FieldValue; |
| 54 | +const Blob = firebase.firestore.Blob; |
| 55 | + |
| 56 | +export { Firestore, FieldValue, FieldPath, Timestamp, Blob, GeoPoint }; |
0 commit comments