Skip to content

Commit 287f365

Browse files
Next attempt
1 parent 5ed0490 commit 287f365

File tree

5 files changed

+65
-20
lines changed

5 files changed

+65
-20
lines changed

integration/firestore/firebase_export.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18-
import * as firebase from 'firebase';
18+
import * as firebase from 'firebase/app';
19+
import 'firebase/firestore';
1920

2021
// This file replaces "packages/firestore/test/integration/util/firebase_export"
2122
// and depends on the minified sources.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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/app';
19+
import 'firebase/firestore/memory';
20+
21+
// This file replaces "packages/firestore/test/integration/util/firebase_export"
22+
// and depends on the minified sources.
23+
24+
let appCount = 0;
25+
26+
export function newTestFirestore(
27+
projectId: string,
28+
nameOrApp?: string | firebase.app.App,
29+
settings?: firebase.firestore.Settings
30+
): firebase.firestore.Firestore {
31+
if (nameOrApp === undefined) {
32+
nameOrApp = 'test-app-' + appCount++;
33+
}
34+
const app =
35+
typeof nameOrApp === 'string'
36+
? firebase.initializeApp({ apiKey: 'fake-api-key', projectId }, nameOrApp)
37+
: nameOrApp;
38+
39+
const firestore = firebase.firestore(app);
40+
if (settings) {
41+
firestore.settings(settings);
42+
}
43+
return firestore;
44+
}
45+
46+
export function usesFunctionalApi(): false {
47+
return false;
48+
}
49+
50+
const Firestore = firebase.firestore.Firestore;
51+
const FieldPath = firebase.firestore.FieldPath;
52+
const Timestamp = firebase.firestore.Timestamp;
53+
const GeoPoint = firebase.firestore.GeoPoint;
54+
const FieldValue = firebase.firestore.FieldValue;
55+
const Blob = firebase.firestore.Blob;
56+
57+
export { Firestore, FieldValue, FieldPath, Timestamp, Blob, GeoPoint };

integration/firestore/gulpfile.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,9 @@ function copyTests() {
3838
* Therefore these tests and helpers cannot have any src/ dependencies.
3939
*/
4040
const testBase = resolve(__dirname, '../../packages/firestore/test');
41-
const firebaseAppSdk = 'firebase/app/dist/index.esm.js';
42-
const firebaseFirestoreSdk = resolve(
43-
__dirname,
44-
isPersistenceEnabled()
45-
? '../../packages/firestore/dist/index.esm.js'
46-
: '../../packages/firestore/dist/index.memory.esm.js'
47-
);
4841
return gulp
4942
.src(
5043
[
51-
'firebase_export.ts',
5244
testBase + '/integration/api/*.ts',
5345
testBase + '/integration/util/events_accumulator.ts',
5446
testBase + '/integration/util/helpers.ts',
@@ -72,7 +64,9 @@ function copyTests() {
7264
/import\s+\* as firebaseExport\s+from\s+('|")[^\1]+firebase_export\1;?/,
7365
`import * as firebaseExport from '${resolve(
7466
__dirname,
75-
'./firebase_export'
67+
isPersistenceEnabled()
68+
? './firebase_export'
69+
: './firebase_export_memory'
7670
)}';
7771
7872
if (typeof process === 'undefined') {
@@ -82,13 +76,6 @@ function copyTests() {
8276
}`
8377
)
8478
)
85-
.pipe(
86-
replace(
87-
'import * as firebase from "firebase";',
88-
`import firebase from '${firebaseAppSdk}';
89-
import '${firebaseFirestoreSdk}';`
90-
)
91-
)
9279
.pipe(
9380
/**
9481
* Fixing the project.json require to properly reference the file

integration/firestore/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"test:persistence": " yarn build:persistence; karma start --single-run",
1212
"test:memory": "yarn build:memory; karma start --single-run",
1313
"test:debug:persistence": "yarn build:deps; yarn build:persistence; karma start --auto-watch --browsers Chrome",
14-
"test:debug:memory": "yarn build:deps; yarn build:memory; karma start --single-run"
14+
"test:debug:memory": "yarn build:deps; yarn build:memory; karma start --auto-watch --browsers Chrome"
1515
},
1616
"devDependencies": {
1717
"@types/mocha": "7.0.2",

packages/firestore/lite/test/integration.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ describe('doc', () => {
155155
it('validates path', () => {
156156
return withTestDb(db => {
157157
expect(() => doc(db, 'coll')).to.throw(
158-
'Invalid document path (coll). Path points to a collection.'
158+
'Invalid document reference. Document references must have an even number of segments, but coll has 1.'
159159
);
160160
expect(() => doc(db, '')).to.throw(
161161
'Function doc() requires its second argument to be of type non-empty string, but it was: ""'
@@ -191,7 +191,7 @@ describe('collection', () => {
191191
it('validates path', () => {
192192
return withTestDb(db => {
193193
expect(() => collection(db, 'coll/doc')).to.throw(
194-
'Invalid collection path (coll/doc). Path points to a document.'
194+
'Invalid collection reference. Collection references must have an odd number of segments, but coll/doc has 2.'
195195
);
196196
// TODO(firestorelite): Explore returning a more helpful message
197197
// (e.g. "Empty document paths are not supported.")

0 commit comments

Comments
 (0)