* Set min mongodb to 3.6 in prep for parse-server 4.0 fixes: 6444 * don't use anonymous functions when we can just pass the function. Also remove the boolean argument in tests that no longer exists. * generate the correct lock file. ooops.
59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
const DatabaseController = require('../lib/Controllers/DatabaseController.js');
|
|
const validateQuery = DatabaseController._validateQuery;
|
|
|
|
describe('DatabaseController', function() {
|
|
describe('validateQuery', function() {
|
|
it('should not restructure simple cases of SERVER-13732', done => {
|
|
const query = {
|
|
$or: [{ a: 1 }, { a: 2 }],
|
|
_rperm: { $in: ['a', 'b'] },
|
|
foo: 3,
|
|
};
|
|
validateQuery(query);
|
|
expect(query).toEqual({
|
|
$or: [{ a: 1 }, { a: 2 }],
|
|
_rperm: { $in: ['a', 'b'] },
|
|
foo: 3,
|
|
});
|
|
done();
|
|
});
|
|
|
|
it('should not restructure SERVER-13732 queries with $nears', done => {
|
|
let query = { $or: [{ a: 1 }, { b: 1 }], c: { $nearSphere: {} } };
|
|
validateQuery(query);
|
|
expect(query).toEqual({
|
|
$or: [{ a: 1 }, { b: 1 }],
|
|
c: { $nearSphere: {} },
|
|
});
|
|
query = { $or: [{ a: 1 }, { b: 1 }], c: { $near: {} } };
|
|
validateQuery(query);
|
|
expect(query).toEqual({ $or: [{ a: 1 }, { b: 1 }], c: { $near: {} } });
|
|
done();
|
|
});
|
|
|
|
it('should not push refactored keys down a tree for SERVER-13732', done => {
|
|
const query = {
|
|
a: 1,
|
|
$or: [{ $or: [{ b: 1 }, { b: 2 }] }, { $or: [{ c: 1 }, { c: 2 }] }],
|
|
};
|
|
validateQuery(query);
|
|
expect(query).toEqual({
|
|
a: 1,
|
|
$or: [{ $or: [{ b: 1 }, { b: 2 }] }, { $or: [{ c: 1 }, { c: 2 }] }],
|
|
});
|
|
|
|
done();
|
|
});
|
|
|
|
it('should reject invalid queries', done => {
|
|
expect(() => validateQuery({ $or: { a: 1 } })).toThrow();
|
|
done();
|
|
});
|
|
|
|
it('should accept valid queries', done => {
|
|
expect(() => validateQuery({ $or: [{ a: 1 }, { b: 2 }] })).not.toThrow();
|
|
done();
|
|
});
|
|
});
|
|
});
|