Merge pull request #3495 from overleaf/ae-prettier-2
Upgrade Prettier to v2 GitOrigin-RevId: 85aa3fa1acb6332c4f58c46165a43d1a51471f33
This commit is contained in:
@@ -12,7 +12,7 @@ const {
|
||||
|
||||
const User = require('./helpers/User').promises
|
||||
|
||||
describe('MongoTests', function() {
|
||||
describe('MongoTests', function () {
|
||||
let userIdAsString, userEmail, userIds
|
||||
beforeEach(async function setUpUsers() {
|
||||
// the first user in the db should not match the target user
|
||||
@@ -31,7 +31,7 @@ describe('MongoTests', function() {
|
||||
userIds = [otherUser.id, user.id, yetAnotherUser.id]
|
||||
})
|
||||
|
||||
describe('normalizeQuery', function() {
|
||||
describe('normalizeQuery', function () {
|
||||
async function expectToWork(blob) {
|
||||
const query = normalizeQuery(blob)
|
||||
|
||||
@@ -44,21 +44,21 @@ describe('MongoTests', function() {
|
||||
expect(user.email).to.equal(userEmail)
|
||||
}
|
||||
|
||||
it('should work with the user id as string', async function() {
|
||||
it('should work with the user id as string', async function () {
|
||||
await expectToWork(userIdAsString)
|
||||
})
|
||||
|
||||
it('should work with the user id in an object', async function() {
|
||||
it('should work with the user id in an object', async function () {
|
||||
await expectToWork({ _id: userIdAsString })
|
||||
})
|
||||
|
||||
it('should pass back the object with id', function() {
|
||||
it('should pass back the object with id', function () {
|
||||
const inputQuery = { _id: userIdAsString, other: 1 }
|
||||
const query = normalizeMultiQuery(inputQuery)
|
||||
expect(inputQuery).to.equal(query)
|
||||
})
|
||||
|
||||
describe('with an ObjectId from mongoose', function() {
|
||||
describe('with an ObjectId from mongoose', function () {
|
||||
let user
|
||||
beforeEach(async function getUser() {
|
||||
user = await UserModel.findById(userIdAsString).exec()
|
||||
@@ -67,16 +67,16 @@ describe('MongoTests', function() {
|
||||
expect(user.email).to.equal(userEmail)
|
||||
})
|
||||
|
||||
it('should have a mongoose ObjectId', function() {
|
||||
it('should have a mongoose ObjectId', function () {
|
||||
expect(user._id).to.be.instanceof(MongooseObjectId)
|
||||
})
|
||||
|
||||
it('should work with the users _id field', async function() {
|
||||
it('should work with the users _id field', async function () {
|
||||
await expectToWork(user._id)
|
||||
})
|
||||
})
|
||||
|
||||
describe('with an ObjectId from the native driver', function() {
|
||||
describe('with an ObjectId from the native driver', function () {
|
||||
let user
|
||||
beforeEach(async function getUser() {
|
||||
user = await db.users.findOne({ _id: NativeObjectId(userIdAsString) })
|
||||
@@ -85,17 +85,17 @@ describe('MongoTests', function() {
|
||||
expect(user.email).to.equal(userEmail)
|
||||
})
|
||||
|
||||
it('should have a native ObjectId', function() {
|
||||
it('should have a native ObjectId', function () {
|
||||
expect(user._id).to.be.instanceof(NativeObjectId)
|
||||
})
|
||||
|
||||
it('should work with the users _id field', async function() {
|
||||
it('should work with the users _id field', async function () {
|
||||
await expectToWork(user._id)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('normalizeMultiQuery', function() {
|
||||
describe('normalizeMultiQuery', function () {
|
||||
let ghost
|
||||
beforeEach(async function addGhost() {
|
||||
// add a user which is not part of the initial three users
|
||||
@@ -113,7 +113,7 @@ describe('MongoTests', function() {
|
||||
)
|
||||
}
|
||||
|
||||
describe('with an array as query', function() {
|
||||
describe('with an array as query', function () {
|
||||
function expectInQueryWithNativeObjectIds(query) {
|
||||
expect(query).to.exist
|
||||
expect(query._id).to.exist
|
||||
@@ -123,47 +123,47 @@ describe('MongoTests', function() {
|
||||
).to.deep.equal([true, true, true])
|
||||
}
|
||||
|
||||
it('should transform all strings to native ObjectIds', function() {
|
||||
it('should transform all strings to native ObjectIds', function () {
|
||||
const query = normalizeMultiQuery(userIds)
|
||||
expectInQueryWithNativeObjectIds(query)
|
||||
})
|
||||
it('should transform all Mongoose ObjectIds to native ObjectIds', function() {
|
||||
it('should transform all Mongoose ObjectIds to native ObjectIds', function () {
|
||||
const query = normalizeMultiQuery(userIds.map(MongooseObjectId))
|
||||
expectInQueryWithNativeObjectIds(query)
|
||||
})
|
||||
it('should leave all native Objects as native ObjectIds', function() {
|
||||
it('should leave all native Objects as native ObjectIds', function () {
|
||||
const query = normalizeMultiQuery(userIds.map(NativeObjectId))
|
||||
expectInQueryWithNativeObjectIds(query)
|
||||
})
|
||||
|
||||
it('should find the three users from string ids', async function() {
|
||||
it('should find the three users from string ids', async function () {
|
||||
const query = normalizeMultiQuery(userIds)
|
||||
await expectToFindTheThreeUsers(query)
|
||||
})
|
||||
it('should find the three users from Mongoose ObjectIds', async function() {
|
||||
it('should find the three users from Mongoose ObjectIds', async function () {
|
||||
const query = normalizeMultiQuery(userIds.map(MongooseObjectId))
|
||||
await expectToFindTheThreeUsers(query)
|
||||
})
|
||||
it('should find the three users from native ObjectIds', async function() {
|
||||
it('should find the three users from native ObjectIds', async function () {
|
||||
const query = normalizeMultiQuery(userIds.map(NativeObjectId))
|
||||
await expectToFindTheThreeUsers(query)
|
||||
})
|
||||
})
|
||||
|
||||
describe('with an object as query', function() {
|
||||
describe('with an object as query', function () {
|
||||
beforeEach(async function addHiddenFlag() {
|
||||
// add a mongo field that does not exist on the other users
|
||||
await ghost.mongoUpdate({ $set: { hidden: 1 } })
|
||||
})
|
||||
|
||||
it('should pass through the query', function() {
|
||||
it('should pass through the query', function () {
|
||||
const inputQuery = { complex: 1 }
|
||||
const query = normalizeMultiQuery(inputQuery)
|
||||
expect(inputQuery).to.equal(query)
|
||||
})
|
||||
|
||||
describe('when searching for hidden users', function() {
|
||||
it('should match the ghost only', async function() {
|
||||
describe('when searching for hidden users', function () {
|
||||
it('should match the ghost only', async function () {
|
||||
const query = normalizeMultiQuery({ hidden: 1 })
|
||||
|
||||
const users = await db.users.find(query).toArray()
|
||||
@@ -172,8 +172,8 @@ describe('MongoTests', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when searching for non hidden users', function() {
|
||||
it('should find the three users', async function() {
|
||||
describe('when searching for non hidden users', function () {
|
||||
it('should find the three users', async function () {
|
||||
const query = normalizeMultiQuery({ hidden: { $exists: false } })
|
||||
|
||||
await expectToFindTheThreeUsers(query)
|
||||
|
||||
Reference in New Issue
Block a user