|
1 | 1 | 'use strict';
|
2 | 2 |
|
3 | 3 | const { expect } = require('chai');
|
4 |
| -const Sinon = require('sinon'); |
5 |
| -const { Promise: BluebirdPromise } = require('bluebird'); |
6 |
| -const { PromiseProvider } = require('../../../src/promise_provider'); |
7 | 4 |
|
8 | 5 | describe('Cursor Async Iterator Tests', function () {
|
9 | 6 | context('default promise library', function () {
|
@@ -83,58 +80,4 @@ describe('Cursor Async Iterator Tests', function () {
|
83 | 80 | expect(count).to.equal(1);
|
84 | 81 | });
|
85 | 82 | });
|
86 |
| - context('custom promise library', () => { |
87 |
| - let client, collection, promiseSpy; |
88 |
| - beforeEach(async function () { |
89 |
| - promiseSpy = Sinon.spy(BluebirdPromise.prototype, 'then'); |
90 |
| - client = this.configuration.newClient({}, { promiseLibrary: BluebirdPromise }); |
91 |
| - |
92 |
| - const connectPromise = client.connect(); |
93 |
| - expect(connectPromise).to.be.instanceOf(BluebirdPromise); |
94 |
| - await connectPromise; |
95 |
| - const docs = Array.from({ length: 1 }).map((_, index) => ({ foo: index, bar: 1 })); |
96 |
| - |
97 |
| - collection = client.db(this.configuration.db).collection('async_cursor_tests'); |
98 |
| - |
99 |
| - await collection.deleteMany({}); |
100 |
| - await collection.insertMany(docs); |
101 |
| - await client.close(); |
102 |
| - }); |
103 |
| - |
104 |
| - beforeEach(async function () { |
105 |
| - client = this.configuration.newClient(); |
106 |
| - await client.connect(); |
107 |
| - collection = client.db(this.configuration.db).collection('async_cursor_tests'); |
108 |
| - }); |
109 |
| - |
110 |
| - afterEach(() => { |
111 |
| - promiseSpy.restore(); |
112 |
| - PromiseProvider.set(null); |
113 |
| - return client.close(); |
114 |
| - }); |
115 |
| - |
116 |
| - it('should properly use custom promise', async function () { |
117 |
| - const cursor = collection.find(); |
118 |
| - const countBeforeIteration = promiseSpy.callCount; |
119 |
| - for await (const doc of cursor) { |
120 |
| - expect(doc).to.exist; |
121 |
| - } |
122 |
| - expect(countBeforeIteration).to.not.equal(promiseSpy.callCount); |
123 |
| - expect(promiseSpy.called).to.equal(true); |
124 |
| - }); |
125 |
| - |
126 |
| - it('should properly use custom promise manual iteration', async function () { |
127 |
| - const cursor = collection.find(); |
128 |
| - |
129 |
| - const iterator = cursor[Symbol.asyncIterator](); |
130 |
| - let isDone; |
131 |
| - do { |
132 |
| - const promiseFromIterator = iterator.next(); |
133 |
| - expect(promiseFromIterator).to.be.instanceOf(BluebirdPromise); |
134 |
| - const { done, value } = await promiseFromIterator; |
135 |
| - if (done) expect(value).to.be.a('undefined'); |
136 |
| - isDone = done; |
137 |
| - } while (!isDone); |
138 |
| - }); |
139 |
| - }); |
140 | 83 | });
|
0 commit comments