|
1 | 1 | import { expect } from 'chai';
|
2 | 2 |
|
3 | 3 | import {
|
4 |
| - type AggregationCursor, |
| 4 | + AggregationCursor, |
5 | 5 | CursorTimeoutMode,
|
6 | 6 | MongoAPIError,
|
7 |
| - MongoClient |
| 7 | + MongoClient, |
| 8 | + ns |
8 | 9 | } from '../../mongodb';
|
9 | 10 |
|
10 | 11 | describe('class AggregationCursor', () => {
|
@@ -140,21 +141,21 @@ describe('class AggregationCursor', () => {
|
140 | 141 | .aggregate([], { timeoutMS: 100, timeoutMode: CursorTimeoutMode.ITERATION });
|
141 | 142 | });
|
142 | 143 |
|
143 |
| - context('when a $out stage is add with .addStage()', () => { |
| 144 | + context('when a $out stage is added with .addStage()', () => { |
144 | 145 | it('throws a MongoAPIError', function () {
|
145 | 146 | expect(() => {
|
146 | 147 | aggregationCursor.addStage({ $out: 'test' });
|
147 | 148 | }).to.throw(MongoAPIError);
|
148 | 149 | });
|
149 | 150 | });
|
150 |
| - context('when a $merge stage is add with .addStage()', () => { |
| 151 | + context('when a $merge stage is added with .addStage()', () => { |
151 | 152 | it('throws a MongoAPIError', function () {
|
152 | 153 | expect(() => {
|
153 | 154 | aggregationCursor.addStage({ $merge: {} });
|
154 | 155 | }).to.throw(MongoAPIError);
|
155 | 156 | });
|
156 | 157 | });
|
157 |
| - context('when a $out stage is add with .out()', () => { |
| 158 | + context('when a $out stage is added with .out()', () => { |
158 | 159 | it('throws a MongoAPIError', function () {
|
159 | 160 | expect(() => {
|
160 | 161 | aggregationCursor.out('test');
|
@@ -198,22 +199,26 @@ describe('class AggregationCursor', () => {
|
198 | 199 | describe('constructor()', () => {
|
199 | 200 | context('when CSOT is enabled', () => {
|
200 | 201 | context('when timeoutMode=ITERATION and a $out stage is provided', function () {
|
201 |
| - const client = new MongoClient('mongodb://iLoveJavascript', { timeoutMS: 100 }); |
202 |
| - expect(() => { |
203 |
| - client |
204 |
| - .db('test') |
205 |
| - .collection('test') |
206 |
| - .aggregate([{ $out: 'test' }], { timeoutMode: CursorTimeoutMode.ITERATION }); |
207 |
| - }).to.throw(MongoAPIError); |
| 202 | + it('throws a MongoAPIError', function () { |
| 203 | + expect( |
| 204 | + () => |
| 205 | + new AggregationCursor(client, ns('db.coll'), [{ $out: 'test' }], { |
| 206 | + timeoutMS: 100, |
| 207 | + timeoutMode: 'iteration' |
| 208 | + }) |
| 209 | + ).to.throw(MongoAPIError); |
| 210 | + }); |
208 | 211 | });
|
209 | 212 | context('when timeoutMode=ITERATION and a $merge stage is provided', function () {
|
210 |
| - const client = new MongoClient('mongodb://iLoveJavascript', { timeoutMS: 100 }); |
211 |
| - expect(() => { |
212 |
| - client |
213 |
| - .db('test') |
214 |
| - .collection('test') |
215 |
| - .aggregate([{ $merge: 'test' }], { timeoutMode: CursorTimeoutMode.ITERATION }); |
216 |
| - }).to.throw(MongoAPIError); |
| 213 | + it('throws a MongoAPIError', function () { |
| 214 | + expect( |
| 215 | + () => |
| 216 | + new AggregationCursor(client, ns('db.coll'), [{ $merge: 'test' }], { |
| 217 | + timeoutMS: 100, |
| 218 | + timeoutMode: 'iteration' |
| 219 | + }) |
| 220 | + ).to.throw(MongoAPIError); |
| 221 | + }); |
217 | 222 | });
|
218 | 223 | });
|
219 | 224 | });
|
|
0 commit comments