Skip to content

Commit

Permalink
feat(initializeApp): add function to create new GeoFirestore instance
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSolati committed Jun 22, 2020
1 parent 4fa8603 commit bb31990
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 98 deletions.
89 changes: 3 additions & 86 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@
"nyc": "^15.1.0",
"protobufjs": "github:michaelsolati/protobuf.js",
"rollup": "^2.14.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^6.1.0",
"rollup-plugin-typescript2": "^0.27.1",
"ts-node": "^8.10.2",
Expand Down
16 changes: 8 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export {GeoFirestoreTypes} from 'geofirestore-core';

export * from './GeoCollectionReference';
export * from './GeoDocumentReference';
export * from './GeoDocumentSnapshot';
export * from './GeoFirestore';
export * from './GeoQuery';
export * from './GeoTransaction';
export * from './GeoWriteBatch';
export {GeoCollectionReference} from './GeoCollectionReference';
export {GeoDocumentReference} from './GeoDocumentReference';
export {GeoDocumentSnapshot} from './GeoDocumentSnapshot';
export {GeoFirestore} from './GeoFirestore';
export {GeoQuery} from './GeoQuery';
export {GeoTransaction} from './GeoTransaction';
export {GeoWriteBatch} from './GeoWriteBatch';
export {initializeApp} from './utils';
12 changes: 12 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
import {GeoFirestoreTypes} from 'geofirestore-core';
import {GeoFirestore} from './GeoFirestore';

/**
* Initializes GeoFirestore instance.
* @param firestore Firestore represents a Firestore Database and is the entry point for all Firestore operations.
* @return GeoFirestore instance.
*/
export function initializeApp(
firestore: GeoFirestoreTypes.web.Firestore | GeoFirestoreTypes.cloud.Firestore
): GeoFirestore {
return new GeoFirestore(firestore);
}

/**
* Remove customKey attribute so firestore doesn't' reject.
Expand Down
11 changes: 9 additions & 2 deletions test/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import * as chai from 'chai';

import {sanitizeSetOptions} from '../src/utils';
import {dummySetOptions} from './common';
import {GeoFirestore} from '../src/GeoFirestore';
import {initializeApp, sanitizeSetOptions} from '../src/utils';
import {dummySetOptions, firestore} from './common';

const expect = chai.expect;

describe('Utils Tests:', () => {
describe('Initialize App:', () => {
it('initializeApp() returns new instance of GeoFirestore', () => {
expect(initializeApp(firestore)).to.be.instanceOf(GeoFirestore)
});
});

describe('Sanitize SetOptions:', () => {
it('sanitizeSetOptions() removes firestore-invalid keys from SetOptions', () => {
const {merge, mergeFields} = dummySetOptions;
Expand Down

0 comments on commit bb31990

Please sign in to comment.