Skip to content

Commit

Permalink
Validate that at least one argument is provided for Cursor (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian authored Nov 5, 2018
1 parent 58a6114 commit 1b214aa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
16 changes: 8 additions & 8 deletions dev/src/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1355,9 +1355,9 @@ export class Query {
*/
startAt(...fieldValuesOrDocumentSnapshot: Array<DocumentSnapshot|UserInput>):
Query {
const options = extend(true, {}, this._queryOptions);
this._validator.minNumberOfArguments('startAt', arguments, 1);

fieldValuesOrDocumentSnapshot = [].slice.call(arguments);
const options = extend(true, {}, this._queryOptions);

const fieldOrders =
this.createImplicitOrderBy(fieldValuesOrDocumentSnapshot);
Expand Down Expand Up @@ -1390,9 +1390,9 @@ export class Query {
*/
startAfter(...fieldValuesOrDocumentSnapshot:
Array<DocumentSnapshot|UserInput>): Query {
const options = extend(true, {}, this._queryOptions);
this._validator.minNumberOfArguments('startAfter', arguments, 1);

fieldValuesOrDocumentSnapshot = [].slice.call(arguments);
const options = extend(true, {}, this._queryOptions);

const fieldOrders =
this.createImplicitOrderBy(fieldValuesOrDocumentSnapshot);
Expand Down Expand Up @@ -1424,9 +1424,9 @@ export class Query {
*/
endBefore(...fieldValuesOrDocumentSnapshot:
Array<DocumentSnapshot|UserInput>): Query {
const options = extend(true, {}, this._queryOptions);
this._validator.minNumberOfArguments('endBefore', arguments, 1);

fieldValuesOrDocumentSnapshot = [].slice.call(arguments);
const options = extend(true, {}, this._queryOptions);

const fieldOrders =
this.createImplicitOrderBy(fieldValuesOrDocumentSnapshot);
Expand Down Expand Up @@ -1458,9 +1458,9 @@ export class Query {
*/
endAt(...fieldValuesOrDocumentSnapshot: Array<DocumentSnapshot|UserInput>):
Query {
const options = extend(true, {}, this._queryOptions);
this._validator.minNumberOfArguments('endAt', arguments, 1);

fieldValuesOrDocumentSnapshot = [].slice.call(arguments);
const options = extend(true, {}, this._queryOptions);

const fieldOrders =
this.createImplicitOrderBy(fieldValuesOrDocumentSnapshot);
Expand Down
8 changes: 8 additions & 0 deletions dev/test/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,14 @@ describe('startAt() interface', () => {
/Only a direct child can be used as a query boundary. Found: 'coll\/doc\/coll\/doc\/coll'./);
});

it('requires at least one value', () => {
const query = firestore.collection('coll/doc/coll');

expect(() => {
query.startAt();
}).to.throw(/Function 'startAt\(\)' requires at least 1 argument./);
});

it('can specify document snapshot', () => {
const overrides = {
runQuery: (request) => {
Expand Down

0 comments on commit 1b214aa

Please sign in to comment.