Skip to content

Commit 0d0aba4

Browse files
Fix minified tests
1 parent 44b61ee commit 0d0aba4

File tree

7 files changed

+33
-63
lines changed

7 files changed

+33
-63
lines changed

integration/firestore/firebase_export.ts

+12-35
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
* limitations under the License.
1616
*/
1717

18-
import firebase from '@firebase/app-compat';
19-
import '@firebase/firestore-compat';
20-
import { FirebaseApp } from '@firebase/app-types';
21-
import { Settings, FirebaseFirestore } from '@firebase/firestore-types';
18+
import { FirebaseApp, initializeApp } from '@firebase/app';
19+
import {
20+
Firestore,
21+
FirestoreSettings,
22+
initializeFirestore
23+
} from '@firebase/firestore';
2224

2325
// This file replaces "packages/firestore/test/integration/util/firebase_export"
2426
// and depends on the minified sources.
@@ -28,43 +30,18 @@ let appCount = 0;
2830
export function newTestFirestore(
2931
projectId: string,
3032
nameOrApp?: string | FirebaseApp,
31-
settings?: Settings
32-
): FirebaseFirestore {
33+
settings?: FirestoreSettings
34+
): Firestore {
3335
if (nameOrApp === undefined) {
3436
nameOrApp = 'test-app-' + appCount++;
3537
}
3638
const app =
3739
typeof nameOrApp === 'string'
38-
? firebase.initializeApp({ apiKey: 'fake-api-key', projectId }, nameOrApp)
40+
? initializeApp({ apiKey: 'fake-api-key', projectId }, nameOrApp)
3941
: nameOrApp;
40-
41-
const firestore = firebase.firestore(app);
42-
if (settings) {
43-
firestore.settings(settings);
44-
}
45-
return firestore;
42+
return initializeFirestore(app, settings || {});
4643
}
4744

48-
export function usesFunctionalApi(): false {
49-
return false;
50-
}
51-
52-
const Blob = firebase.firestore.Blob;
53-
const DocumentReference = firebase.firestore.DocumentReference;
54-
const FieldPath = firebase.firestore.FieldPath;
55-
const FieldValue = firebase.firestore.FieldValue;
56-
const Firestore = firebase.firestore.Firestore;
57-
const GeoPoint = firebase.firestore.GeoPoint;
58-
const QueryDocumentSnapshot = firebase.firestore.QueryDocumentSnapshot;
59-
const Timestamp = firebase.firestore.Timestamp;
45+
export * from '@firebase/firestore';
6046

61-
export {
62-
Blob,
63-
DocumentReference,
64-
FieldPath,
65-
FieldValue,
66-
Firestore,
67-
GeoPoint,
68-
QueryDocumentSnapshot,
69-
Timestamp
70-
};
47+
export type PrivateSettings = Record<string, any>;

integration/firestore/gulpfile.js

+10-17
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,18 @@ function copyTests() {
5353
.pipe(
5454
replace(
5555
/**
56-
* This regex is designed to match the following statement used in our
57-
* firestore integration test suites:
58-
*
59-
* import * as firebaseExport from '../../util/firebase_export';
60-
*
61-
* It will handle variations in whitespace, single/double quote
62-
* differences, as well as different paths to a valid firebase_export
56+
* This regex is designed to match the Firebase import in our
57+
* integration tests.
6358
*/
64-
/import\s+\* as firebaseExport\s+from\s+('|")[^\1]+firebase_export\1;?/,
65-
`import * as firebaseExport from '${resolve(
66-
__dirname,
67-
'./firebase_export'
68-
)}';
59+
/\s+from '\.(\.\/util)?\/firebase_export';/,
60+
` from '${resolve(__dirname, './firebase_export')}';
6961
70-
if (typeof process === 'undefined') {
71-
process = { env: { INCLUDE_FIRESTORE_PERSISTENCE: '${isPersistenceEnabled()}' } } as any;
72-
} else {
73-
process.env.INCLUDE_FIRESTORE_PERSISTENCE = '${isPersistenceEnabled()}';
74-
}`
62+
if (typeof process === 'undefined') {
63+
process = { env: { INCLUDE_FIRESTORE_PERSISTENCE: '${isPersistenceEnabled()}' } } as any;
64+
} else {
65+
process.env.INCLUDE_FIRESTORE_PERSISTENCE = '${isPersistenceEnabled()}';
66+
}
67+
`
7568
)
7669
)
7770
.pipe(

integration/firestore/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"build:deps": "lerna run --scope @firebase/'{app,firestore}' --include-dependencies build",
77
"build:persistence": "INCLUDE_FIRESTORE_PERSISTENCE=true gulp compile-tests",
88
"build:memory": "INCLUDE_FIRESTORE_PERSISTENCE=false gulp compile-tests",
9+
"prettier": "prettier --write '*.js' '*.ts'",
910
"test": "yarn build:memory; karma start --single-run; yarn build:persistence; karma start --single-run;",
1011
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test",
1112
"test:persistence": " yarn build:persistence; karma start --single-run",
@@ -15,7 +16,7 @@
1516
},
1617
"devDependencies": {
1718
"@firebase/app": "0.7.11",
18-
"@firebase/firestore-compat": "0.1.10",
19+
"@firebase/firestore": "3.4.1",
1920
"@types/mocha": "9.0.0",
2021
"gulp": "4.0.2",
2122
"gulp-filter": "7.0.0",

packages/firestore/test/integration/util/events_accumulator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import { expect } from 'chai';
1919

20-
import { DocumentSnapshot, QuerySnapshot } from '../../../src';
20+
import { DocumentSnapshot, QuerySnapshot } from './firebase_export';
2121
import { Deferred } from '../../util/promise';
2222

2323
/**

packages/firestore/test/integration/util/firebase_export.ts

+1
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ export function newTestFirestore(
5353
}
5454

5555
export * from '../../../src';
56+
export { PrivateSettings };

packages/firestore/test/integration/util/helpers.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import { isIndexedDBAvailable } from '@firebase/util';
1919

20-
import * as firebaseExport from './firebase_export';
2120
import {
2221
collection,
2322
doc,
@@ -26,21 +25,20 @@ import {
2625
terminate,
2726
clearIndexedDbPersistence,
2827
enableIndexedDbPersistence,
29-
Settings,
3028
CollectionReference,
3129
DocumentData,
3230
QuerySnapshot,
3331
setDoc,
34-
SnapshotListenOptions
32+
PrivateSettings,
33+
SnapshotListenOptions,
34+
newTestFirestore
3535
} from './firebase_export';
3636
import {
3737
ALT_PROJECT_ID,
3838
DEFAULT_PROJECT_ID,
3939
DEFAULT_SETTINGS
4040
} from './settings';
4141

42-
const newTestFirestore = firebaseExport.newTestFirestore;
43-
4442
/* eslint-disable no-restricted-globals */
4543

4644
function isIeOrEdge(): boolean {
@@ -173,7 +171,7 @@ export function withTestDbs(
173171
export async function withTestDbsSettings(
174172
persistence: boolean,
175173
projectId: string,
176-
settings: Settings,
174+
settings: PrivateSettings,
177175
numDbs: number,
178176
fn: (db: Firestore[]) => Promise<void>
179177
): Promise<void> {
@@ -214,7 +212,7 @@ export function withTestDoc(
214212

215213
export function withTestDocAndSettings(
216214
persistence: boolean,
217-
settings: Settings,
215+
settings: PrivateSettings,
218216
fn: (doc: DocumentReference) => Promise<void>
219217
): Promise<void> {
220218
return withTestDbsSettings(
@@ -260,7 +258,7 @@ export function withTestCollection(
260258
// return the same collection every time.
261259
export function withTestCollectionSettings(
262260
persistence: boolean,
263-
settings: Settings,
261+
settings: PrivateSettings,
264262
docs: { [key: string]: DocumentData },
265263
fn: (collection: CollectionReference, db: Firestore) => Promise<void>
266264
): Promise<void> {

packages/firestore/test/integration/util/settings.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { PrivateSettings } from '../../../src/lite-api/settings';
18+
import { PrivateSettings } from './firebase_export';
1919

2020
/**
2121
* NOTE: These helpers are used by api/ tests and therefore may not have any

0 commit comments

Comments
 (0)