Skip to content

Commit 198e11d

Browse files
--amend
1 parent 6b37f2c commit 198e11d

18 files changed

+59
-197
lines changed

packages/firestore/karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
const karmaBase = require('../../config/karma.base');
1919
const { argv } = require('yargs');
2020

21-
module.exports = function(config) {
21+
module.exports = function (config) {
2222
const karmaConfig = Object.assign({}, karmaBase, {
2323
// files to load into karma
2424
files: getTestFiles(argv),

packages/firestore/rollup.shared.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const pkg = require('./package.json');
2929
* references to platform-specific files with implementations for the provided
3030
* target platform.
3131
*/
32-
exports.generateAliasConfig = function(platform) {
32+
exports.generateAliasConfig = function (platform) {
3333
return {
3434
entries: [
3535
{
@@ -47,12 +47,12 @@ const browserDeps = Object.keys(
4747
const nodeDeps = [...browserDeps, 'util', 'path'];
4848

4949
/** Resolves the external dependencies for the browser build. */
50-
exports.resolveBrowserExterns = function(id) {
50+
exports.resolveBrowserExterns = function (id) {
5151
return browserDeps.some(dep => id === dep || id.startsWith(`${dep}/`));
5252
};
5353

5454
/** Resolves the external dependencies for the Node build. */
55-
exports.resolveNodeExterns = function(id) {
55+
exports.resolveNodeExterns = function (id) {
5656
return nodeDeps.some(dep => id === dep || id.startsWith(`${dep}/`));
5757
};
5858

packages/firestore/src/local/simple_db.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,7 @@ export class SimpleDb {
218218
static getIOSVersion(ua: string): number {
219219
const iOSVersionRegex = ua.match(/i(?:phone|pad|pod) os ([\d_]+)/i);
220220
const version = iOSVersionRegex
221-
? iOSVersionRegex[1]
222-
.split('_')
223-
.slice(0, 2)
224-
.join('.')
221+
? iOSVersionRegex[1].split('_').slice(0, 2).join('.')
225222
: '-1';
226223
return Number(version);
227224
}
@@ -231,10 +228,7 @@ export class SimpleDb {
231228
static getAndroidVersion(ua: string): number {
232229
const androidVersionRegex = ua.match(/Android ([\d.]+)/i);
233230
const version = androidVersionRegex
234-
? androidVersionRegex[1]
235-
.split('.')
236-
.slice(0, 2)
237-
.join('.')
231+
? androidVersionRegex[1].split('.').slice(0, 2).join('.')
238232
: '-1';
239233
return Number(version);
240234
}

packages/firestore/src/platform/format_json.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717

1818
// This file is only used under ts-node.
1919
// eslint-disable-next-line @typescript-eslint/no-require-imports
20-
const platform = require(`./${process.env.TEST_PLATFORM ??
21-
'node'}/format_json`);
20+
const platform = require(`./${
21+
process.env.TEST_PLATFORM ?? 'node'
22+
}/format_json`);
2223

2324
/** Formats an object as a JSON string, suitable for logging. */
2425
export function formatJSON(value: unknown): string {

packages/firestore/src/platform/random_bytes.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717

1818
// This file is only used under ts-node.
1919
// eslint-disable-next-line @typescript-eslint/no-require-imports
20-
const platform = require(`./${process.env.TEST_PLATFORM ??
21-
'node'}/random_bytes`);
20+
const platform = require(`./${
21+
process.env.TEST_PLATFORM ?? 'node'
22+
}/random_bytes`);
2223

2324
/**
2425
* Generates `nBytes` of random bytes.

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,7 @@ apiDescribe('Database batch writes', (persistence: boolean) => {
7676
return integrationHelpers.withTestDoc(persistence, doc => {
7777
return doc
7878
.set({ foo: 'bar' })
79-
.then(() =>
80-
doc.firestore
81-
.batch()
82-
.update(doc, { baz: 42 })
83-
.commit()
84-
)
79+
.then(() => doc.firestore.batch().update(doc, { baz: 42 }).commit())
8580
.then(() => doc.get())
8681
.then(snapshot => {
8782
expect(snapshot.exists).to.equal(true);
@@ -126,12 +121,7 @@ apiDescribe('Database batch writes', (persistence: boolean) => {
126121
.then(snapshot => {
127122
expect(snapshot.exists).to.equal(true);
128123
})
129-
.then(() =>
130-
doc.firestore
131-
.batch()
132-
.delete(doc)
133-
.commit()
134-
)
124+
.then(() => doc.firestore.batch().delete(doc).commit())
135125
.then(() => doc.get())
136126
.then(snapshot => {
137127
expect(snapshot.exists).to.equal(false);

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ apiDescribe('Cursors', (persistence: boolean) => {
4848
.then(docs => {
4949
expect(toDataArray(docs)).to.deep.equal([{ v: 'a' }, { v: 'b' }]);
5050
const lastDoc = docs.docs[docs.docs.length - 1];
51-
return coll
52-
.limit(3)
53-
.startAfter(lastDoc)
54-
.get();
51+
return coll.limit(3).startAfter(lastDoc).get();
5552
})
5653
.then(docs => {
5754
expect(toDataArray(docs)).to.deep.equal([
@@ -60,18 +57,12 @@ apiDescribe('Cursors', (persistence: boolean) => {
6057
{ v: 'e' }
6158
]);
6259
const lastDoc = docs.docs[docs.docs.length - 1];
63-
return coll
64-
.limit(1)
65-
.startAfter(lastDoc)
66-
.get();
60+
return coll.limit(1).startAfter(lastDoc).get();
6761
})
6862
.then(docs => {
6963
expect(toDataArray(docs)).to.deep.equal([{ v: 'f' }]);
7064
const lastDoc = docs.docs[docs.docs.length - 1];
71-
return coll
72-
.limit(3)
73-
.startAfter(lastDoc)
74-
.get();
65+
return coll.limit(3).startAfter(lastDoc).get();
7566
})
7667
.then(docs => {
7768
expect(toDataArray(docs)).to.deep.equal([]);

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -660,16 +660,10 @@ apiDescribe('Database', (persistence: boolean) => {
660660
it('inequality same as first orderBy works.', () => {
661661
return withTestCollection(persistence, {}, async coll => {
662662
expect(() =>
663-
coll
664-
.where('x', '>', 32)
665-
.orderBy('x')
666-
.orderBy('y')
663+
coll.where('x', '>', 32).orderBy('x').orderBy('y')
667664
).not.to.throw();
668665
expect(() =>
669-
coll
670-
.orderBy('x')
671-
.where('x', '>', 32)
672-
.orderBy('y')
666+
coll.orderBy('x').where('x', '>', 32).orderBy('y')
673667
).not.to.throw();
674668
});
675669
});

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

Lines changed: 16 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,7 @@ apiDescribe('Database transactions', (persistence: boolean) => {
207207
return integrationHelpers.withTestDb(persistence, async db => {
208208
const tt = new TransactionTester(db);
209209

210-
await tt
211-
.withExistingDoc()
212-
.run(get, delete1, delete1)
213-
.expectNoDoc();
210+
await tt.withExistingDoc().run(get, delete1, delete1).expectNoDoc();
214211
await tt
215212
.withExistingDoc()
216213
.run(get, delete1, update2)
@@ -220,10 +217,7 @@ apiDescribe('Database transactions', (persistence: boolean) => {
220217
.run(get, delete1, set2)
221218
.expectDoc({ foo: 'bar2' });
222219

223-
await tt
224-
.withExistingDoc()
225-
.run(get, update1, delete1)
226-
.expectNoDoc();
220+
await tt.withExistingDoc().run(get, update1, delete1).expectNoDoc();
227221
await tt
228222
.withExistingDoc()
229223
.run(get, update1, update2)
@@ -233,10 +227,7 @@ apiDescribe('Database transactions', (persistence: boolean) => {
233227
.run(get, update1, set2)
234228
.expectDoc({ foo: 'bar2' });
235229

236-
await tt
237-
.withExistingDoc()
238-
.run(get, set1, delete1)
239-
.expectNoDoc();
230+
await tt.withExistingDoc().run(get, set1, delete1).expectNoDoc();
240231
await tt
241232
.withExistingDoc()
242233
.run(get, set1, update2)
@@ -252,10 +243,7 @@ apiDescribe('Database transactions', (persistence: boolean) => {
252243
return integrationHelpers.withTestDb(persistence, async db => {
253244
const tt = new TransactionTester(db);
254245

255-
await tt
256-
.withNonexistentDoc()
257-
.run(get, delete1, delete1)
258-
.expectNoDoc();
246+
await tt.withNonexistentDoc().run(get, delete1, delete1).expectNoDoc();
259247
await tt
260248
.withNonexistentDoc()
261249
.run(get, delete1, update2)
@@ -278,10 +266,7 @@ apiDescribe('Database transactions', (persistence: boolean) => {
278266
.run(get, update1, set1)
279267
.expectError('invalid-argument');
280268

281-
await tt
282-
.withNonexistentDoc()
283-
.run(get, set1, delete1)
284-
.expectNoDoc();
269+
await tt.withNonexistentDoc().run(get, set1, delete1).expectNoDoc();
285270
await tt
286271
.withNonexistentDoc()
287272
.run(get, set1, update2)
@@ -297,55 +282,31 @@ apiDescribe('Database transactions', (persistence: boolean) => {
297282
return integrationHelpers.withTestDb(persistence, async db => {
298283
const tt = new TransactionTester(db);
299284

300-
await tt
301-
.withExistingDoc()
302-
.run(delete1, delete1)
303-
.expectNoDoc();
285+
await tt.withExistingDoc().run(delete1, delete1).expectNoDoc();
304286
await tt
305287
.withExistingDoc()
306288
.run(delete1, update2)
307289
.expectError('invalid-argument');
308-
await tt
309-
.withExistingDoc()
310-
.run(delete1, set2)
311-
.expectDoc({ foo: 'bar2' });
290+
await tt.withExistingDoc().run(delete1, set2).expectDoc({ foo: 'bar2' });
312291

313-
await tt
314-
.withExistingDoc()
315-
.run(update1, delete1)
316-
.expectNoDoc();
292+
await tt.withExistingDoc().run(update1, delete1).expectNoDoc();
317293
await tt
318294
.withExistingDoc()
319295
.run(update1, update2)
320296
.expectDoc({ foo: 'bar2' });
321-
await tt
322-
.withExistingDoc()
323-
.run(update1, set2)
324-
.expectDoc({ foo: 'bar2' });
297+
await tt.withExistingDoc().run(update1, set2).expectDoc({ foo: 'bar2' });
325298

326-
await tt
327-
.withExistingDoc()
328-
.run(set1, delete1)
329-
.expectNoDoc();
330-
await tt
331-
.withExistingDoc()
332-
.run(set1, update2)
333-
.expectDoc({ foo: 'bar2' });
334-
await tt
335-
.withExistingDoc()
336-
.run(set1, set2)
337-
.expectDoc({ foo: 'bar2' });
299+
await tt.withExistingDoc().run(set1, delete1).expectNoDoc();
300+
await tt.withExistingDoc().run(set1, update2).expectDoc({ foo: 'bar2' });
301+
await tt.withExistingDoc().run(set1, set2).expectDoc({ foo: 'bar2' });
338302
});
339303
});
340304

341305
it('runs transactions on non-existent document', async () => {
342306
return integrationHelpers.withTestDb(persistence, async db => {
343307
const tt = new TransactionTester(db);
344308

345-
await tt
346-
.withNonexistentDoc()
347-
.run(delete1, delete1)
348-
.expectNoDoc();
309+
await tt.withNonexistentDoc().run(delete1, delete1).expectNoDoc();
349310
await tt
350311
.withNonexistentDoc()
351312
.run(delete1, update2)
@@ -363,23 +324,14 @@ apiDescribe('Database transactions', (persistence: boolean) => {
363324
.withNonexistentDoc()
364325
.run(update1, update2)
365326
.expectError('not-found');
366-
await tt
367-
.withNonexistentDoc()
368-
.run(update1, set1)
369-
.expectError('not-found');
327+
await tt.withNonexistentDoc().run(update1, set1).expectError('not-found');
370328

371-
await tt
372-
.withNonexistentDoc()
373-
.run(set1, delete1)
374-
.expectNoDoc();
329+
await tt.withNonexistentDoc().run(set1, delete1).expectNoDoc();
375330
await tt
376331
.withNonexistentDoc()
377332
.run(set1, update2)
378333
.expectDoc({ foo: 'bar2' });
379-
await tt
380-
.withNonexistentDoc()
381-
.run(set1, set2)
382-
.expectDoc({ foo: 'bar2' });
334+
await tt.withNonexistentDoc().run(set1, set2).expectDoc({ foo: 'bar2' });
383335
});
384336
});
385337

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

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -567,19 +567,13 @@ apiDescribe('Validation:', (persistence: boolean) => {
567567
return ref
568568
.set(data)
569569
.then(() => {
570-
return ref.firestore
571-
.batch()
572-
.set(ref, data)
573-
.commit();
570+
return ref.firestore.batch().set(ref, data).commit();
574571
})
575572
.then(() => {
576573
return ref.update(data);
577574
})
578575
.then(() => {
579-
return ref.firestore
580-
.batch()
581-
.update(ref, data)
582-
.commit();
576+
return ref.firestore.batch().update(ref, data).commit();
583577
})
584578
.then(() => {
585579
return ref.firestore.runTransaction(async txn => {
@@ -1140,16 +1134,10 @@ apiDescribe('Validation:', (persistence: boolean) => {
11401134
reason
11411135
);
11421136
expect(() =>
1143-
collection
1144-
.where('x', '>', 32)
1145-
.orderBy('y')
1146-
.orderBy('x')
1137+
collection.where('x', '>', 32).orderBy('y').orderBy('x')
11471138
).to.throw(reason);
11481139
expect(() =>
1149-
collection
1150-
.orderBy('y')
1151-
.orderBy('x')
1152-
.where('x', '>', 32)
1140+
collection.orderBy('y').orderBy('x').where('x', '>', 32)
11531141
).to.throw(reason);
11541142
}
11551143
);

packages/firestore/test/integration/prime_backend.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const PRIMING_TIMEOUT_MS = 45000;
2727

2828
before(
2929
'Prime backend by waiting for a write to show up in the watch stream',
30-
function(): Promise<void> {
30+
function (): Promise<void> {
3131
this.timeout(PRIMING_TIMEOUT_MS);
3232

3333
return withTestDoc(/*persistence=*/ false, async doc => {

packages/firestore/test/unit/local/mutation_queue.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,7 @@ function genericMutationQueueTests(): void {
244244
}
245245
const expected = [batches[1], batches[2], batches[4]];
246246
const matches = await mutationQueue.getAllMutationBatchesAffectingDocumentKeys(
247-
documentKeySet()
248-
.add(key('foo/bar'))
249-
.add(key('foo/baz'))
247+
documentKeySet().add(key('foo/bar')).add(key('foo/baz'))
250248
);
251249
expectEqualArrays(matches, expected);
252250
});

packages/firestore/test/unit/local/remote_document_cache.test.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,7 @@ function genericRemoteDocumentCacheTests(
304304
return cache
305305
.addEntries(docs, version(VERSION))
306306
.then(() => {
307-
return cache.getEntries(
308-
documentKeySet()
309-
.add(key1)
310-
.add(key2)
311-
);
307+
return cache.getEntries(documentKeySet().add(key1).add(key2));
312308
})
313309
.then(read => {
314310
expectEqual(read.get(key1), docs[0]);
@@ -328,10 +324,7 @@ function genericRemoteDocumentCacheTests(
328324
.addEntries(docs, version(VERSION))
329325
.then(() => {
330326
return cache.getEntries(
331-
documentKeySet()
332-
.add(key1)
333-
.add(key2)
334-
.add(missingKey)
327+
documentKeySet().add(key1).add(key2).add(missingKey)
335328
);
336329
})
337330
.then(read => {

0 commit comments

Comments
 (0)