Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assert.throws(() => {
query.orderBy(Firestore.FieldPath.documentId())
.startAt(firestore.doc('coll/doc/other/doc'));
}, /'coll\/doc\/other\/doc' is not part of the query result set and cannot be used as a query boundary./);
assert.throws(() => {
query.orderBy(Firestore.FieldPath.documentId())
.startAt(firestore.doc('coll/doc/coll_suffix/doc'));
}, /'coll\/doc\/coll_suffix\/doc' is not part of the query result set and cannot be used as a query boundary./);
assert.throws(() => {
query.orderBy(Firestore.FieldPath.documentId())
.startAt(firestore.doc('coll/doc'));
}, /'coll\/doc' is not part of the query result set and cannot be used as a query boundary./);
assert.throws(() => {
query.orderBy(Firestore.FieldPath.documentId())
.startAt(firestore.doc('coll/doc/coll/doc/coll/doc'));
}, /Only a direct child can be used as a query boundary. Found: 'coll\/doc\/coll\/doc\/coll\/doc'./);
// Validate that we can't pass a reference to a collection.
assert.throws(() => {
query.orderBy(Firestore.FieldPath.documentId()).startAt('doc/coll');
}, /Only a direct child can be used as a query boundary. Found: 'coll\/doc\/coll\/doc\/coll'./);
});
it('with invalid last update time precondition', function() {
assert.throws(() => {
return firestore.doc('collectionId/documentId').delete({
lastUpdateTime: 1337
});
}, /"lastUpdateTime" is not a Firestore Timestamp./);
});
it('doesn\'t accept arrays', function() {
assert.throws(() => {
firestore.doc('collectionId/documentId').create([42]);
}, /Argument "data" is not a valid Document. Input is not a plain JavaScript object./);
});
});
it('verifies field path', function() {
let query = firestore.collection('collectionId');
assert.throws(function() {
query = query.orderBy('foo.', '=', 'foobar');
}, /Argument "fieldPath" is not a valid FieldPath. Paths must not start or end with '.'./);
});
it('rejects invalid NaN filter', function() {
assert.throws(() => {
let query = firestore.collection('collectionId');
query = query.where('foo', '>', NaN);
return query.get();
}, /Invalid query. You can only perform equals comparisons on NaN\./);
});
it('requires collection id', function() {
assert.throws(function() {
firestore.collection();
}, /Argument "collectionPath" is not a valid ResourcePath. Path must be a non-empty string./);
});
let query = firestore.collection('collectionId');
assert.throws(() => {
query.where('foo', '=', new Foo()).get();
}, /Argument "value" is not a valid QueryValue. Couldn't serialize object of type "Foo". Firestore doesn't support JavaScript objects with custom prototypes \(i.e. objects that were created via the 'new' operator\)./);
assert.throws(() => {
query.where('foo', '=', new FieldPath()).get();
}, /Detected an object of type "FieldPath" that doesn't match the expected instance./);
assert.throws(() => {
query.where('foo', '=', new FieldValue()).get();
}, /Detected an object of type "FieldValue" that doesn't match the expected instance./);
assert.throws(() => {
query.where('foo', '=', new DocumentReference()).get();
}, /Detected an object of type "DocumentReference" that doesn't match the expected instance./);
assert.throws(() => {
query.where('foo', '=', new GeoPoint()).get();
}, /Detected an object of type "GeoPoint" that doesn't match the expected instance./);
});
assert.throws(() => {
firestore.doc('collectionId/documentId').update({
foo: 'foobar',
'foo.bar.foobar': 'foobar',
});
}, /Argument "dataOrField" is not a valid UpdateMap. Field "foo" was specified multiple times\./);
assert.throws(() => {
firestore.doc('collectionId/documentId').update({
'foo.bar': 'foobar',
foo: 'foobar',
});
}, /Argument "dataOrField" is not a valid UpdateMap. Field "foo" was specified multiple times\./);
assert.throws(() => {
firestore.doc('collectionId/documentId').update({
'foo.bar': 'foobar',
'foo.bar.foo': 'foobar',
});
}, /Argument "dataOrField" is not a valid UpdateMap. Field "foo.bar" was specified multiple times\./);
assert.throws(() => {
firestore.doc('collectionId/documentId').update({
'foo.bar': {foo: 'foobar'},
'foo.bar.foo': 'foobar',
});
}, /Argument "dataOrField" is not a valid UpdateMap. Field "foo.bar" was specified multiple times\./);
assert.throws(() => {
firestore.doc('collectionId/documentId')
.update('foo.bar', 'foobar', 'foo', 'foobar');
return snapshot('collectionId/doc', {}).then(doc => {
assert.throws(() => {
query.startAt(doc);
}, /Field 'foo' is missing in the provided DocumentSnapshot. Please provide a document that contains values for all specified orderBy\(\) and where\(\) constraints./);
});
});
new Firestore.GeoPoint();
}, /Argument "latitude" is not a valid number/);
assert.throws(() => {
new Firestore.GeoPoint(NaN);
}, /Argument "latitude" is not a valid number/);
assert.throws(() => {
new Firestore.GeoPoint(Infinity);
}, /Argument "latitude" is not a valid number/);
assert.throws(() => {
new Firestore.GeoPoint(91, 0);
}, /Argument "latitude" is not a valid number. Value must be within \[-90, 90] inclusive, but was: 91/);
assert.throws(() => {
new Firestore.GeoPoint(90, 181);
}, /Argument "longitude" is not a valid number. Value must be within \[-180, 180] inclusive, but was: 181/);
});