Skip to content

Commit 8dbe197

Browse files
Share Integration Tests between firestore-exp and the main SDK
1 parent ddddda8 commit 8dbe197

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+997
-918
lines changed

integration/firestore/gulpfile.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,36 @@ function copyTests() {
6363
* This regex is designed to match the following statement used in our
6464
* firestore integration test suites:
6565
*
66-
* import firebase from '../../util/firebase_export';
66+
* import * as firebaseExport from '../../util/firebase_export';
6767
*
6868
* It will handle variations in whitespace, single/double quote
6969
* differences, as well as different paths to a valid firebase_export
7070
*/
71-
/import\s+firebase\s+from\s+('|")[^\1]+firebase_export\1;?/,
71+
/import\s+\* as firebaseExport\s+from\s+('|")[^\1]+firebase_export\1;?/,
7272
`import firebase from '${firebaseAppSdk}';
7373
import '${firebaseFirestoreSdk}';
74+
75+
const firebaseExport = firebase.firestore;
76+
77+
// Abuse 'window' object to share a global variable between all tests
78+
(window as any).appCount = (window as any).appCount || 0;
79+
firebaseExport.newTestFirestore = function(projectId, nameOrApp, settings) {
80+
if (nameOrApp === undefined) {
81+
nameOrApp = 'test-app-' + (window as any).appCount++;
82+
}
83+
const app =
84+
typeof nameOrApp === 'string'
85+
? firebase.initializeApp({ apiKey: 'fake-api-key', projectId }, nameOrApp)
86+
: nameOrApp;
87+
88+
const firestore = firebase.firestore(app);
89+
if (settings) {
90+
firestore.settings(settings);
91+
}
92+
return firestore;
93+
}
94+
95+
firebaseExport.usesModularApi = () => false;
7496
7597
if (typeof process === 'undefined') {
7698
process = { env: { INCLUDE_FIRESTORE_PERSISTENCE: '${isPersistenceEnabled()}' } } as any;

packages/firestore/.idea/runConfigurations/firestore_exp_Tests__Emulator__.xml

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/firestore/.idea/runConfigurations/firestore_exp_Tests__Emulator_w__Mock_Persistence_.xml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/firestore/exp/src/api/database.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ export function disableNetwork(
289289
export function terminate(
290290
firestore: firestore.FirebaseFirestore
291291
): Promise<void> {
292-
_removeServiceInstance(firestore.app, 'firestore/lite');
292+
_removeServiceInstance(firestore.app, 'firestore-exp');
293293
const firestoreImpl = cast(firestore, Firestore);
294294
return firestoreImpl._terminate();
295295
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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 '../../test/integration/api/array_transforms.test';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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 '../../test/integration/api/batch_writes.test';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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 '../../test/integration/api/cursor.test';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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 '../../test/integration/api/database.test';

0 commit comments

Comments
 (0)