| 96 | } |
| 97 | |
| 98 | async function finished() { |
| 99 | let count = await collection.find().count(); |
| 100 | test.equal(10, count); |
| 101 | test.ok(count.constructor === Number); |
| 102 | |
| 103 | count = await collection.find({}, { limit: 5 }).count(); |
| 104 | test.equal(5, count); |
| 105 | |
| 106 | count = await collection.find({}, { skip: 5 }).count(); |
| 107 | test.equal(5, count); |
| 108 | |
| 109 | count = await db.collection('acollectionthatdoesn').count(); |
| 110 | |
| 111 | test.equal(0, count); |
| 112 | |
| 113 | const cursor = collection.find(); |
| 114 | count = await cursor.count(); |
| 115 | test.equal(10, count); |
| 116 | |
| 117 | await cursor.forEach(() => { |
| 118 | // do nothing |
| 119 | }); |
| 120 | |
| 121 | const count2 = await cursor.count(); |
| 122 | expect(count2).to.equal(10); |
| 123 | expect(count2).to.equal(count); |
| 124 | } |
| 125 | |
| 126 | await insert(); |
| 127 | await finished(); |