Skip to content

Commit e45b40f

Browse files
Actually using TSLint for the test files
1 parent 11a1d7b commit e45b40f

39 files changed

+58
-80
lines changed

packages/firestore/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
66
"scripts": {
77
"dev": "gulp dev",
8-
"lint": "tslint -p tsconfig.json -c tslint.json src/**/*.ts test/**/*.ts",
9-
"lint:fix": "tslint --fix -p tsconfig.json -c tslint.json src/**/*.ts test/**/*.ts",
8+
"lint": "tslint -p tsconfig.json -c tslint.json 'src/**/*.ts' 'test/**/*.ts'",
9+
"lint:fix": "tslint --fix -p tsconfig.json -c tslint.json 'src/**/*.ts' 'test/**/*.ts'",
1010
"test": "run-s lint test:all",
1111
"test:all": "run-p test:browser test:node",
1212
"test:browser": "karma start --single-run",

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
withTestDb,
2626
withTestDoc
2727
} from '../util/helpers';
28+
import {query} from '../../util/api_helpers';
2829

2930
const Timestamp = firebase.firestore.Timestamp;
3031

@@ -419,7 +420,7 @@ apiDescribe('Database', persistence => {
419420
// client-side validation but fail remotely. May need to wait until we
420421
// have security rules support or something?
421422
xdescribe('Listens are rejected remotely:', () => {
422-
let queryForRejection: firestore.Query;
423+
const queryForRejection = query("foo");
423424

424425
it('will reject listens', () => {
425426
const deferred = new Deferred();

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
apiDescribe,
2121
DEFAULT_SETTINGS,
2222
toDataArray,
23-
toIds,
2423
withTestCollection,
2524
withTestCollectionSettings,
2625
withTestDoc
@@ -29,8 +28,11 @@ import {
2928
const FieldPath = firebase.firestore.FieldPath;
3029
const Timestamp = firebase.firestore.Timestamp;
3130

31+
// tslint:disable-next-line:no-any Allow custom type for testing.
32+
type AnyTestData = any;
33+
3234
apiDescribe('Nested Fields', persistence => {
33-
const testData = (n?: number): any => {
35+
const testData = (n?: number): AnyTestData => {
3436
n = n || 1;
3537
return {
3638
name: 'room ' + n,
@@ -235,7 +237,7 @@ apiDescribe('Nested Fields', persistence => {
235237
// Datastore currently prohibits having nested fields and fields with dots in
236238
// the same entity, so I'm separating them.
237239
apiDescribe('Fields with special characters', persistence => {
238-
const testData = (n?: number): any => {
240+
const testData = (n?: number): AnyTestData => {
239241
n = n || 1;
240242
return {
241243
field: 'field ' + n,
@@ -341,7 +343,8 @@ apiDescribe('Fields with special characters', persistence => {
341343
});
342344

343345
apiDescribe('Timestamp Fields in snapshots', persistence => {
344-
const testDataWithTimestamps = (ts: any): any => {
346+
// tslint:disable-next-line:no-any Figure out how to pass in the Timestamp type
347+
const testDataWithTimestamps = (ts: any): AnyTestData => {
345348
return { timestamp: ts, nested: { timestamp2: ts } };
346349
};
347350

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ import firebase from '../util/firebase_export';
2323
import {
2424
apiDescribe,
2525
toDataArray,
26-
withTestCollection,
27-
withTestDbs
26+
withTestCollection
2827
} from '../util/helpers';
2928
import { Deferred } from '../../util/promise';
3029

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { expect } from 'chai';
1818
import * as firestore from '@firebase/firestore-types';
1919

2020
import firebase from '../util/firebase_export';
21-
import { apiDescribe, DEFAULT_SETTINGS, withTestDoc } from '../util/helpers';
21+
import { apiDescribe, withTestDoc } from '../util/helpers';
2222
import { EventsAccumulator } from '../util/events_accumulator';
2323

2424
const Timestamp = firebase.firestore.Timestamp;

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,15 +375,16 @@ apiDescribe('Database transactions', persistence => {
375375
return integrationHelpers.withTestDb(persistence, db => {
376376
const doc1 = db.collection('counters').doc();
377377
const doc2 = db.collection('counters').doc();
378-
let tries = 0;
378+
// let tries = 0;
379379
return (
380380
doc1
381381
.set({
382382
count: 15
383383
})
384384
.then(() => {
385385
return db.runTransaction(transaction => {
386-
tries++;
386+
// ++tries;
387+
387388
// Get the first doc.
388389
return (
389390
transaction

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,20 @@ const validationIt: ValidationIt = Object.assign(
6666
});
6767
},
6868
{
69-
skip: function(
69+
skip(
7070
persistence: boolean,
7171
message: string,
7272
_: (db: firestore.FirebaseFirestore) => void | Promise<any>
7373
) {
74+
// tslint:disable-next-line:ban
7475
it.skip(message, () => {});
7576
},
76-
only: function(
77+
only(
7778
persistence: boolean,
7879
message: string,
7980
testFunction: (db: firestore.FirebaseFirestore) => void | Promise<any>
8081
) {
82+
// tslint:disable-next-line:ban
8183
it.only(message, () => {
8284
return withTestDb(persistence, async db => {
8385
const maybePromise = testFunction(db);
@@ -305,7 +307,7 @@ apiDescribe('Validation:', persistence => {
305307
describe('Writes', () => {
306308
/** Class used to verify custom classes can't be used in writes. */
307309
class TestClass {
308-
constructor(public readonly property: string) {}
310+
constructor(readonly property: string) {}
309311
}
310312

311313
validationIt(persistence, 'must be objects.', db => {

packages/firestore/test/integration/remote/stream.test.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
} from '../../../src/remote/watch_change';
3131
import { AsyncQueue, TimerId } from '../../../src/util/async_queue';
3232
import { Deferred } from '../../../src/util/promise';
33-
import { Datastore } from '../../../src/remote/datastore';
3433
import { setMutation } from '../../util/helpers';
3534
import { withTestDatastore } from '../util/internal_helpers';
3635
import { FirestoreError } from '@firebase/firestore-types';
@@ -50,7 +49,7 @@ const SINGLE_MUTATION = [setMutation('docs/1', { foo: 'bar' })];
5049

5150
class StreamStatusListener implements WatchStreamListener, WriteStreamListener {
5251
private pendingCallbacks: StreamEventType[] = [];
53-
private pendingPromises: Deferred<StreamEventType>[] = [];
52+
private pendingPromises: Array<Deferred<StreamEventType>> = [];
5453

5554
/**
5655
* Returns a Promise that resolves when the next callback fires. Resolves the
@@ -63,7 +62,7 @@ class StreamStatusListener implements WatchStreamListener, WriteStreamListener {
6362
let promise: Promise<StreamEventType>;
6463

6564
if (this.pendingCallbacks.length > 0) {
66-
let pendingCallback = this.pendingCallbacks.shift();
65+
const pendingCallback = this.pendingCallbacks.shift();
6766
promise = Promise.resolve(pendingCallback);
6867
} else {
6968
const deferred = new Deferred<StreamEventType>();
@@ -114,7 +113,7 @@ class StreamStatusListener implements WatchStreamListener, WriteStreamListener {
114113

115114
private async resolvePending(actualCallback: StreamEventType): Promise<void> {
116115
if (this.pendingPromises.length > 0) {
117-
let pendingPromise = this.pendingPromises.shift();
116+
const pendingPromise = this.pendingPromises.shift();
118117
pendingPromise.resolve(actualCallback);
119118
} else {
120119
this.pendingCallbacks.push(actualCallback);
@@ -154,11 +153,9 @@ describe('Watch Stream', () => {
154153
});
155154

156155
describe('Write Stream', () => {
157-
let queue: AsyncQueue;
158156
let streamListener: StreamStatusListener;
159157

160158
beforeEach(() => {
161-
queue = new AsyncQueue();
162159
streamListener = new StreamStatusListener();
163160
});
164161

@@ -213,10 +210,10 @@ describe('Write Stream', () => {
213210
});
214211

215212
it('closes when idle', () => {
216-
let queue = new AsyncQueue();
213+
const queue = new AsyncQueue();
217214

218215
return withTestDatastore(ds => {
219-
let writeStream = ds.newPersistentWriteStream();
216+
const writeStream = ds.newPersistentWriteStream();
220217
writeStream.start(streamListener);
221218
return streamListener
222219
.awaitCallback('open')
@@ -240,10 +237,10 @@ describe('Write Stream', () => {
240237
});
241238

242239
it('cancels idle on write', () => {
243-
let queue = new AsyncQueue();
240+
const queue = new AsyncQueue();
244241

245242
return withTestDatastore(ds => {
246-
let writeStream = ds.newPersistentWriteStream();
243+
const writeStream = ds.newPersistentWriteStream();
247244
writeStream.start(streamListener);
248245
return streamListener
249246
.awaitCallback('open')

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@
2020
// instead.
2121

2222
import firebase from '@firebase/app';
23+
24+
// tslint:disable-next-line:no-default-export
2325
export default firebase;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export function toDataArray(
8888
}
8989

9090
/** Converts a DocumentSet to an array with the id of each document */
91-
export function toIds(docSet: firestore.QuerySnapshot): String[] {
91+
export function toIds(docSet: firestore.QuerySnapshot): string[] {
9292
return docSet.docs.map(d => d.id);
9393
}
9494

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { Datastore } from '../../../src/remote/datastore';
2121

2222
import { EmptyCredentialsProvider } from '../../../src/api/credentials';
2323
import { PlatformSupport } from '../../../src/platform/platform';
24-
import { AsyncQueue, TimerId } from '../../../src/util/async_queue';
24+
import { AsyncQueue } from '../../../src/util/async_queue';
2525
import { DEFAULT_SETTINGS, DEFAULT_PROJECT_ID } from './helpers';
2626
import { Firestore } from '../../../src/api/database';
2727

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { expect } from 'chai';
18-
import {
19-
CollectionReference,
20-
DocumentReference,
21-
DocumentSnapshot,
22-
Query,
23-
QuerySnapshot
24-
} from '../../../src/api/database';
2517
import {
2618
collectionReference,
2719
documentReference,

packages/firestore/test/unit/api/field_path.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { expect } from 'chai';
18-
import { FieldPath } from '../../../src/api/field_path';
1917
import { field, expectEqual, expectNotEqual } from '../../util/helpers';
2018

2119
describe('FieldPath', () => {

packages/firestore/test/unit/api/field_value.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { expect } from 'chai';
1817
import { PublicFieldValue as FieldValue } from '../../../src/api/field_value';
1918
import { expectEqual, expectNotEqual } from '../../util/helpers';
2019

packages/firestore/test/unit/core/query.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { DOCUMENT_KEY_NAME, ResourcePath } from '../../../src/model/path';
2020
import { addEqualityMatcher } from '../../util/equality_matcher';
2121
import {
2222
bound,
23-
dbId,
2423
doc,
2524
expectCorrectComparisons,
2625
expectEqualitySets,

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,15 @@
1616

1717
import { expect } from 'chai';
1818
import * as EncodedResourcePath from '../../../src/local/encoded_resource_path';
19-
import { PersistenceTransaction } from '../../../src/local/persistence';
20-
import { Persistence } from '../../../src/local/persistence';
2119
import { PersistencePromise } from '../../../src/local/persistence_promise';
2220
import {
2321
SimpleDb,
2422
SimpleDbStore,
2523
SimpleDbTransaction
2624
} from '../../../src/local/simple_db';
2725
import { ResourcePath } from '../../../src/model/path';
28-
import { fail } from '../../../src/util/assert';
2926
import { path } from '../../util/helpers';
3027

31-
import * as persistenceHelpers from './persistence_test_helpers';
3228

3329
let db: SimpleDb;
3430
const sep = '\u0001\u0001';

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ function withDb(
5959
});
6060
}
6161

62-
function getAllObjectStores(db: IDBDatabase): String[] {
63-
const objectStores: String[] = [];
62+
function getAllObjectStores(db: IDBDatabase): string[] {
63+
const objectStores: string[] = [];
6464
for (let i = 0; i < db.objectStoreNames.length; ++i) {
6565
objectStores.push(db.objectStoreNames.item(i));
6666
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { SnapshotVersion } from '../../../src/core/snapshot_version';
2020
import { TargetId } from '../../../src/core/types';
2121
import { EagerGarbageCollector } from '../../../src/local/eager_garbage_collector';
2222
import { IndexedDbPersistence } from '../../../src/local/indexeddb_persistence';
23-
import { MemoryQueryCache } from '../../../src/local/memory_query_cache';
2423
import { Persistence } from '../../../src/local/persistence';
2524
import { QueryData, QueryPurpose } from '../../../src/local/query_data';
2625
import { addEqualityMatcher } from '../../util/equality_matcher';
@@ -35,7 +34,6 @@ import {
3534
import * as persistenceHelpers from './persistence_test_helpers';
3635
import { TestGarbageCollector } from './test_garbage_collector';
3736
import { TestQueryCache } from './test_query_cache';
38-
import { fail } from '../../../src/util/assert';
3937

4038
let persistence: Persistence;
4139
let cache: TestQueryCache;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { expect } from 'chai';
1818
import { ReferenceSet } from '../../../src/local/reference_set';
19-
import { expectSetToEqual, key } from '../../util/helpers';
19+
import { key } from '../../util/helpers';
2020

2121
describe('ReferenceSet', () => {
2222
it('can add/remove references', async () => {

packages/firestore/test/unit/model/field_value.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
blob,
2424
dbId,
2525
expectCorrectComparisonGroups,
26-
expectCorrectComparisons,
2726
expectEqualitySets,
2827
field,
2928
key,

packages/firestore/test/unit/model/path.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('Path', () => {
3838
addEqualityMatcher();
3939

4040
it('can be constructed', () => {
41-
const path = new ResourcePath(['rooms', 'Eros', 'messages']);
41+
const _ = new ResourcePath(['rooms', 'Eros', 'messages']);
4242
});
4343

4444
it('can index into itself', () => {

packages/firestore/test/unit/remote/remote_event.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {
3232
WatchTargetChange,
3333
WatchTargetChangeState
3434
} from '../../../src/remote/watch_change';
35-
import * as objUtils from '../../../src/util/obj';
3635
import {
3736
deletedDoc,
3837
doc,

packages/firestore/test/unit/specs/collection_spec.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { expect } from 'chai';
1817
import { Query } from '../../../src/core/query';
1918
import { doc, path } from '../../util/helpers';
2019

packages/firestore/test/unit/specs/existence_filter_spec.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { expect } from 'chai';
1817
import { Query } from '../../../src/core/query';
1918
import { Code } from '../../../src/util/error';
2019
import { deletedDoc, doc, path } from '../../util/helpers';

packages/firestore/test/unit/specs/limbo_spec.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { expect } from 'chai';
1817
import { Query } from '../../../src/core/query';
1918
import { deletedDoc, doc, filter, path } from '../../util/helpers';
2019

packages/firestore/test/unit/specs/limit_spec.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { expect } from 'chai';
1817
import { Query } from '../../../src/core/query';
1918
import { deletedDoc, doc, path } from '../../util/helpers';
2019

packages/firestore/test/unit/specs/listen_spec.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { expect } from 'chai';
1817
import { Query } from '../../../src/core/query';
1918
import { Code } from '../../../src/util/error';
2019
import { doc, filter, path } from '../../util/helpers';

0 commit comments

Comments
 (0)