Skip to content

Commit 49ae902

Browse files
Fixing minified tests
1 parent 15c781c commit 49ae902

File tree

9 files changed

+45
-58
lines changed

9 files changed

+45
-58
lines changed

packages/firestore/test/integration/api/batch_writes.test.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import * as firestore from 'firestore';
2020
import * as testHelpers from '../../util/helpers';
2121
import firebase from '../util/firebase_export';
2222
import * as integrationHelpers from '../util/helpers';
23+
import { PublicFieldValue } from '../../../src/api/field_value';
24+
import { FieldPath } from '../../../src/api/field_path';
2325

2426
const asyncIt = testHelpers.asyncIt;
2527
const apiDescribe = integrationHelpers.apiDescribe;
@@ -240,10 +242,10 @@ apiDescribe('Database batch writes', persistence => {
240242
collection.firestore
241243
.batch()
242244
.set(docA, {
243-
when: firebase.firestore.FieldValue.serverTimestamp()
245+
when: PublicFieldValue.serverTimestamp()
244246
})
245247
.set(docB, {
246-
when: firebase.firestore.FieldValue.serverTimestamp()
248+
when: PublicFieldValue.serverTimestamp()
247249
})
248250
.commit();
249251

@@ -291,7 +293,7 @@ apiDescribe('Database batch writes', persistence => {
291293
.set(doc, { a: 1, b: 1, when: 'when' })
292294
.update(doc, {
293295
b: 2,
294-
when: firebase.firestore.FieldValue.serverTimestamp()
296+
when: PublicFieldValue.serverTimestamp()
295297
})
296298
.commit();
297299

@@ -330,13 +332,7 @@ apiDescribe('Database batch writes', persistence => {
330332
return doc.firestore
331333
.batch()
332334
.set(doc, initialData)
333-
.update(
334-
doc,
335-
'owner.name',
336-
'Sebastian',
337-
new firebase.firestore.FieldPath('is.admin'),
338-
true
339-
)
335+
.update(doc, 'owner.name', 'Sebastian', new FieldPath('is.admin'), true)
340336
.commit()
341337
.then(() => doc.get())
342338
.then(docSnapshot => {

packages/firestore/test/integration/api/cursor.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
withTestDb,
2424
withTestDbs
2525
} from '../util/helpers';
26+
import { FieldPath } from '../../../src/api/field_path';
2627

2728
apiDescribe('Cursors', persistence => {
2829
asyncIt('can page through items', () => {
@@ -164,7 +165,7 @@ apiDescribe('Cursors', persistence => {
164165
return Promise.all(sets)
165166
.then(() => {
166167
return readerCollection
167-
.orderBy(firebase.firestore.FieldPath.documentId())
168+
.orderBy(FieldPath.documentId())
168169
.startAt('b')
169170
.endBefore('d')
170171
.get();
@@ -215,7 +216,7 @@ apiDescribe('Cursors', persistence => {
215216
const query = coll
216217
.orderBy('sort', 'desc')
217218
// default indexes reverse the key ordering for descending sorts
218-
.orderBy(firebase.firestore.FieldPath.documentId(), 'desc');
219+
.orderBy(FieldPath.documentId(), 'desc');
219220
return query
220221
.startAt(2)
221222
.get()

packages/firestore/test/integration/api/database.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import {
2626
withTestDb,
2727
withTestDoc
2828
} from '../util/helpers';
29+
import { PublicFieldValue } from '../../../src/api/field_value';
30+
import { FieldPath } from '../../../src/api/field_path';
2931

3032
apiDescribe('Database', persistence => {
3133
asyncIt('can set a document', () => {
@@ -126,7 +128,7 @@ apiDescribe('Database', persistence => {
126128
updated: false
127129
};
128130
const mergeData = {
129-
time: firebase.firestore.FieldValue.serverTimestamp()
131+
time: PublicFieldValue.serverTimestamp()
130132
};
131133
return doc
132134
.set(initialData)
@@ -148,8 +150,8 @@ apiDescribe('Database', persistence => {
148150
nested: { untouched: true, foo: 'bar' }
149151
};
150152
const mergeData = {
151-
foo: firebase.firestore.FieldValue.delete(),
152-
nested: { foo: firebase.firestore.FieldValue.delete() }
153+
foo: PublicFieldValue.delete(),
154+
nested: { foo: PublicFieldValue.delete() }
153155
};
154156
const finalData = {
155157
untouched: true,
@@ -222,7 +224,7 @@ apiDescribe('Database', persistence => {
222224
owner: { name: 'Jonny', email: '[email protected]' }
223225
};
224226
const updateData = {
225-
'owner.email': firebase.firestore.FieldValue.delete()
227+
'owner.email': PublicFieldValue.delete()
226228
};
227229
const finalData = {
228230
desc: 'Description',
@@ -240,8 +242,6 @@ apiDescribe('Database', persistence => {
240242
});
241243

242244
asyncIt('can update nested fields', () => {
243-
const FieldPath = firebase.firestore.FieldPath;
244-
245245
return withTestDoc(persistence, doc => {
246246
const initialData = {
247247
desc: 'Description',

packages/firestore/test/integration/api/fields.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import { expect } from 'chai';
1818
import { asyncIt, toDataArray } from '../../util/helpers';
1919
import firebase from '../util/firebase_export';
2020
import { apiDescribe, withTestCollection, withTestDoc } from '../util/helpers';
21-
22-
const FieldPath = firebase.firestore.FieldPath;
21+
import { FieldPath } from '../../../src/api/field_path';
2322

2423
apiDescribe('Nested Fields', persistence => {
2524
const testData = (n?: number): any => {

packages/firestore/test/integration/api/query.test.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import firebase from '../util/firebase_export';
2323
import { apiDescribe, withTestCollection, withTestDbs } from '../util/helpers';
2424
import { Firestore } from '../../../src/api/database';
2525
import { Deferred } from '../../../src/util/promise';
26+
import { FieldPath } from '../../../src/api/field_path';
2627

2728
apiDescribe('Queries', persistence => {
2829
addEqualityMatcher();
@@ -359,7 +360,7 @@ apiDescribe('Queries', persistence => {
359360
// Ideally this would be descending to validate it's different than
360361
// the default, but that requires an extra index
361362
return coll
362-
.orderBy(firebase.firestore.FieldPath.documentId())
363+
.orderBy(FieldPath.documentId())
363364
.get()
364365
.then(docs => {
365366
expect(toDataArray(docs)).to.deep.equal([
@@ -380,13 +381,13 @@ apiDescribe('Queries', persistence => {
380381
};
381382
return withTestCollection(persistence, testDocs, coll => {
382383
return coll
383-
.where(firebase.firestore.FieldPath.documentId(), '==', 'ab')
384+
.where(FieldPath.documentId(), '==', 'ab')
384385
.get()
385386
.then(docs => {
386387
expect(toDataArray(docs)).to.deep.equal([testDocs['ab']]);
387388
return coll
388-
.where(firebase.firestore.FieldPath.documentId(), '>', 'aa')
389-
.where(firebase.firestore.FieldPath.documentId(), '<=', 'ba')
389+
.where(FieldPath.documentId(), '>', 'aa')
390+
.where(FieldPath.documentId(), '<=', 'ba')
390391
.get();
391392
})
392393
.then(docs => {
@@ -407,21 +408,13 @@ apiDescribe('Queries', persistence => {
407408
};
408409
return withTestCollection(persistence, testDocs, coll => {
409410
return coll
410-
.where(firebase.firestore.FieldPath.documentId(), '==', coll.doc('ab'))
411+
.where(FieldPath.documentId(), '==', coll.doc('ab'))
411412
.get()
412413
.then(docs => {
413414
expect(toDataArray(docs)).to.deep.equal([testDocs['ab']]);
414415
return coll
415-
.where(
416-
firebase.firestore.FieldPath.documentId(),
417-
'>',
418-
coll.doc('aa')
419-
)
420-
.where(
421-
firebase.firestore.FieldPath.documentId(),
422-
'<=',
423-
coll.doc('ba')
424-
)
416+
.where(FieldPath.documentId(), '>', coll.doc('aa'))
417+
.where(FieldPath.documentId(), '<=', coll.doc('ba'))
425418
.get();
426419
})
427420
.then(docs => {

packages/firestore/test/integration/api/server_timestamp.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,23 @@ import * as firestore from 'firestore';
2020
import * as testHelpers from '../../util/helpers';
2121
import firebase from '../util/firebase_export';
2222
import { apiDescribe, withTestDoc } from '../util/helpers';
23+
import { PublicFieldValue } from '../../../src/api/field_value';
2324

2425
const asyncIt = testHelpers.asyncIt;
2526

2627
apiDescribe('Server Timestamps', persistence => {
2728
// Data written in tests via set().
2829
const setData = {
2930
a: 42,
30-
when: firebase.firestore.FieldValue.serverTimestamp(),
31-
deep: { when: firebase.firestore.FieldValue.serverTimestamp() }
31+
when: PublicFieldValue.serverTimestamp(),
32+
deep: { when: PublicFieldValue.serverTimestamp() }
3233
};
3334

3435
// base and update data used for update() tests.
3536
const initialData = { a: 42 };
3637
const updateData = {
37-
when: firebase.firestore.FieldValue.serverTimestamp(),
38-
deep: { when: firebase.firestore.FieldValue.serverTimestamp() }
38+
when: PublicFieldValue.serverTimestamp(),
39+
deep: { when: PublicFieldValue.serverTimestamp() }
3940
};
4041

4142
// A document reference to read and write to.

packages/firestore/test/integration/api/transactions.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { Deferred } from '../../../src/util/promise';
2020
import * as testHelpers from '../../util/helpers';
2121
import firebase from '../util/firebase_export';
2222
import * as integrationHelpers from '../util/helpers';
23+
import { FieldPath } from '../../../src/api/field_path';
2324

2425
const asyncIt = testHelpers.asyncIt;
2526
const apiDescribe = integrationHelpers.apiDescribe;
@@ -365,7 +366,7 @@ apiDescribe('Database transactions', persistence => {
365366
doc,
366367
'owner.name',
367368
'Sebastian',
368-
new firebase.firestore.FieldPath('is.admin'),
369+
new FieldPath('is.admin'),
369370
true
370371
);
371372
return Promise.resolve();

packages/firestore/test/integration/api/type.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import firebase from '../util/firebase_export';
2020
import { apiDescribe, withTestDb, withTestDoc } from '../util/helpers';
2121

2222
import * as testHelpers from '../../util/helpers';
23+
import { GeoPoint } from '../../../src/api/geo_point';
24+
import { PublicBlob } from '../../../src/api/blob';
2325

2426
const asyncIt = testHelpers.asyncIt;
2527

@@ -49,13 +51,13 @@ apiDescribe('Firestore', persistence => {
4951
asyncIt('can read and write geo point fields', () => {
5052
return withTestDoc(persistence, doc => {
5153
return doc
52-
.set({ geopoint: new firebase.firestore.GeoPoint(1.23, 4.56) })
54+
.set({ geopoint: new GeoPoint(1.23, 4.56) })
5355
.then(() => {
5456
return doc.get();
5557
})
5658
.then(docSnapshot => {
5759
const latLong = docSnapshot.data()['geopoint'];
58-
expect(latLong instanceof firebase.firestore.GeoPoint).to.equal(true);
60+
expect(latLong instanceof GeoPoint).to.equal(true);
5961
expect(latLong.latitude).to.equal(1.23);
6062
expect(latLong.longitude).to.equal(4.56);
6163
});
@@ -66,16 +68,14 @@ apiDescribe('Firestore', persistence => {
6668
return withTestDoc(persistence, doc => {
6769
return doc
6870
.set({
69-
bytes: firebase.firestore.Blob.fromUint8Array(
70-
new Uint8Array([0, 1, 255])
71-
)
71+
bytes: PublicBlob.fromUint8Array(new Uint8Array([0, 1, 255]))
7272
})
7373
.then(() => {
7474
return doc.get();
7575
})
7676
.then(docSnapshot => {
7777
const blob = docSnapshot.data()['bytes'];
78-
expect(blob instanceof firebase.firestore.Blob).to.equal(true);
78+
expect(blob instanceof PublicBlob).to.equal(true);
7979
expect(blob.toUint8Array()).to.deep.equal(
8080
new Uint8Array([0, 1, 255])
8181
);

packages/firestore/test/integration/api/validation.test.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import {
2727
withTestCollection,
2828
withTestDb
2929
} from '../util/helpers';
30+
import { PublicFieldValue } from '../../../src/api/field_value';
31+
import { FieldPath } from '../../../src/api/field_path';
3032

3133
// We're using 'as any' to pass invalid values to APIs for testing purposes.
3234
// tslint:disable:no-any
@@ -418,7 +420,7 @@ apiDescribe('Validation:', persistence => {
418420
db => {
419421
return expectSetToFail(
420422
db,
421-
{ foo: firebase.firestore.FieldValue.delete() },
423+
{ foo: PublicFieldValue.delete() },
422424
'FieldValue.delete() can only be used with update() and set() with {merge:true} (found in field foo)'
423425
);
424426
}
@@ -430,7 +432,7 @@ apiDescribe('Validation:', persistence => {
430432
db => {
431433
return expectUpdateToFail(
432434
db,
433-
{ foo: { bar: firebase.firestore.FieldValue.delete() } },
435+
{ foo: { bar: PublicFieldValue.delete() } },
434436
'FieldValue.delete() can only appear at the top level of your ' +
435437
'update data (found in field foo.bar)'
436438
);
@@ -577,9 +579,7 @@ apiDescribe('Validation:', persistence => {
577579
'order-by-key bounds must be strings without slashes.',
578580
db => {
579581
const collection = db.collection('collection');
580-
const query = collection.orderBy(
581-
firebase.firestore.FieldPath.documentId()
582-
);
582+
const query = collection.orderBy(FieldPath.documentId());
583583
expect(() => query.startAt(1)).to.throw(
584584
'Invalid query. Expected a string for document ID in ' +
585585
'Query.startAt(), but got a number'
@@ -659,25 +659,21 @@ apiDescribe('Validation:', persistence => {
659659
db => {
660660
const collection = db.collection('test');
661661
expect(() =>
662-
collection.where(firebase.firestore.FieldPath.documentId(), '>=', '')
662+
collection.where(FieldPath.documentId(), '>=', '')
663663
).to.throw(
664664
'Function Query.where() requires its third parameter to be ' +
665665
'a valid document ID if the first parameter is ' +
666666
'FieldPath.documentId(), but it was an empty string.'
667667
);
668668
expect(() =>
669-
collection.where(
670-
firebase.firestore.FieldPath.documentId(),
671-
'>=',
672-
'foo/bar/baz'
673-
)
669+
collection.where(FieldPath.documentId(), '>=', 'foo/bar/baz')
674670
).to.throw(
675671
'Function Query.where() requires its third parameter to be ' +
676672
'a valid document ID if the first parameter is ' +
677673
'FieldPath.documentId(), but it contains a slash.'
678674
);
679675
expect(() =>
680-
collection.where(firebase.firestore.FieldPath.documentId(), '>=', 1)
676+
collection.where(FieldPath.documentId(), '>=', 1)
681677
).to.throw(
682678
'Function Query.where() requires its third parameter to be ' +
683679
'a string or a DocumentReference if the first parameter is ' +

0 commit comments

Comments
 (0)