Skip to content

Commit

Permalink
test(GeoFirestore): add tests for runTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSolati committed Feb 2, 2019
1 parent 2a58584 commit 23f59ce
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@
"include": [
"src/**/*.ts"
],
"exclude": [
"src/interfaces/*"
],
"reporter": [
"html"
],
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export * from './GeoFirestore';
export * from './GeoFirestoreTypes';
export * from './GeoQuery';
export * from './GeoQuerySnapshot';
export * from './GeoTransaction';
export * from './GeoWriteBatch';
24 changes: 22 additions & 2 deletions test/GeoFirestore.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import * as chai from 'chai';

import { GeoFirestore } from '../src/GeoFirestore';
import { afterEachHelper, beforeEachHelper, firestore, invalidFirestores, testCollectionName } from './common';
import { GeoFirestore, GeoTransaction } from '../src';
import {
afterEachHelper, beforeEachHelper, firestore, invalidFirestores,
testCollectionName, geofirestore, geocollection
} from './common';

const expect = chai.expect;

Expand Down Expand Up @@ -41,4 +44,21 @@ describe('GeoFirestore Tests:', () => {
).to.deep.equal(firestore.collection(testCollectionName));
});
});

describe('runTransaction():', () => {
it('runTransaction() doesn\'t throw an error when a valid `updateFunction` is passed in', () => {
expect(() => {
return geofirestore.runTransaction((transaction) => {
const geotransaction = new GeoTransaction(transaction);
const docRef = geocollection.doc('testdoc');
return geotransaction.get(docRef);
});
}).to.not.throw();
});

it('runTransaction() does throw an error when an invalid `updateFunction` is passed in', (done) => {
// @ts-ignore
geofirestore.runTransaction(() => Math).catch((e) => done());
});
});
});

0 comments on commit 23f59ce

Please sign in to comment.