(config)
| 69 | |
| 70 | context('#findOneAndModify', () => { |
| 71 | async function testFindOneAndUpdate(config) { |
| 72 | const client = new MongoClient(`mongodb://${server.uri()}/test`); |
| 73 | |
| 74 | server.setMessageHandler(request => { |
| 75 | const doc = request.document; |
| 76 | if (doc.findAndModify) { |
| 77 | expect(doc.bypassDocumentValidation).equal(config.expected); |
| 78 | request.reply({ |
| 79 | ok: 1 |
| 80 | }); |
| 81 | } |
| 82 | |
| 83 | if (isHello(doc)) { |
| 84 | request.reply(Object.assign({}, HELLO)); |
| 85 | } else if (doc.endSessions) { |
| 86 | request.reply({ ok: 1 }); |
| 87 | } |
| 88 | }); |
| 89 | |
| 90 | await client.connect(); |
| 91 | const db = client.db('test'); |
| 92 | const collection = db.collection('test_c'); |
| 93 | |
| 94 | const options = { bypassDocumentValidation: config.actual }; |
| 95 | |
| 96 | await collection.findOneAndUpdate({ name: 'Andy' }, { $inc: { score: 1 } }, options); |
| 97 | await client.close(); |
| 98 | } |
| 99 | |
| 100 | it('should only set bypass document validation if strictly true in findOneAndUpdate', async function () { |
| 101 | await testFindOneAndUpdate({ expected: true, actual: true }); |
no test coverage detected