Skip to content

Commit 22c62f6

Browse files
chore(lint): Clean database + utils
1 parent 5462c36 commit 22c62f6

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

src/database/database.spec.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { COMMON_CONFIG } from '../test-config';
55
import { NgZone } from '@angular/core';
66
import 'firebase/database';
77
import { rando } from '../firestore/utils.spec';
8+
import { Test } from 'tslint';
89

910
describe('AngularFireDatabase', () => {
1011
let app: FirebaseApp;
@@ -23,11 +24,10 @@ describe('AngularFireDatabase', () => {
2324
{ provide: URL, useValue: 'http://localhost:9000'}
2425
]
2526
});
26-
inject([FirebaseApp, AngularFireDatabase, NgZone], (app_: FirebaseApp, _db: AngularFireDatabase, _zone: NgZone) => {
27-
app = app_;
28-
db = _db;
29-
zone = _zone;
30-
})();
27+
28+
app = TestBed.inject(FirebaseApp);
29+
db = TestBed.inject(AngularFireDatabase);
30+
zone = TestBed.inject(NgZone);
3131
});
3232

3333
afterEach(() => {
@@ -45,9 +45,9 @@ describe('AngularFireDatabase', () => {
4545
});
4646

4747
it('should accept a Firebase App in the constructor', (done) => {
48-
const __db = new AngularFireDatabase(app.options, rando(), undefined!, {}, zone);
49-
expect(__db instanceof AngularFireDatabase).toEqual(true);
50-
__db.database.app.delete().then(done, done);
48+
const database = new AngularFireDatabase(app.options, rando(), undefined, {}, zone);
49+
expect(database instanceof AngularFireDatabase).toEqual(true);
50+
database.database.app.delete().then(done, done);
5151
});
5252

5353
it('should have an initialized Firebase app instance member', () => {

src/database/database.ts

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export class AngularFireDatabase {
2323
@Inject(FIREBASE_OPTIONS) options: FirebaseOptions,
2424
@Optional() @Inject(FIREBASE_APP_NAME) nameOrConfig: string|FirebaseAppConfig|null|undefined,
2525
@Optional() @Inject(URL) databaseURL: string|null,
26+
// tslint:disable-next-line:ban-types
2627
@Inject(PLATFORM_ID) platformId: Object,
2728
zone: NgZone
2829
) {

src/database/utils.spec.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ describe('utils', () => {
1111
const nul = null;
1212
const obj = {};
1313
const fn = () => { };
14-
let undef;
14+
const undef = undefined;
1515
expect(utils.isString(str)).toBe(true);
1616
expect(utils.isString(notStr)).toBe(false);
1717
expect(utils.isString(bool)).toBe(false);
1818
expect(utils.isString(nul)).toBe(false);
19+
expect(utils.isString(obj)).toBe(false);
1920
expect(utils.isString(fn)).toBe(false);
2021
expect(utils.isString(undef)).toBe(false);
2122
});

src/database/utils.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ export function isFirebaseRef(value: any): boolean {
2020
/**
2121
* Returns a database reference given a Firebase App and an
2222
* absolute or relative path.
23-
* @param app - Firebase App
24-
* @param path - Database path, relative or absolute
23+
* @param database - Firebase Database
24+
* @param pathRef - Database path, relative or absolute
2525
*/
2626
export function getRef(database: database.Database, pathRef: PathReference): DatabaseReference {
2727
// if a db ref was passed in, just return it
@@ -33,9 +33,9 @@ export function checkOperationCases(item: FirebaseOperation, cases: FirebaseOper
3333
if (isString(item)) {
3434
return cases.stringCase();
3535
} else if (isFirebaseRef(item)) {
36-
return cases.firebaseCase!();
36+
return cases.firebaseCase();
3737
} else if (isFirebaseDataSnapshot(item)) {
38-
return cases.snapshotCase!();
38+
return cases.snapshotCase();
3939
}
4040
throw new Error(`Expects a string, snapshot, or reference. Got: ${typeof item}`);
4141
}

0 commit comments

Comments
 (0)