Skip to content

Commit 494992e

Browse files
committed
fix test
1 parent 505fd73 commit 494992e

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

test/unit/cursor/aggregation_cursor.test.ts

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { expect } from 'chai';
22

33
import {
4-
type AggregationCursor,
4+
AggregationCursor,
55
CursorTimeoutMode,
66
MongoAPIError,
7-
MongoClient
7+
MongoClient,
8+
ns
89
} from '../../mongodb';
910

1011
describe('class AggregationCursor', () => {
@@ -140,21 +141,21 @@ describe('class AggregationCursor', () => {
140141
.aggregate([], { timeoutMS: 100, timeoutMode: CursorTimeoutMode.ITERATION });
141142
});
142143

143-
context('when a $out stage is add with .addStage()', () => {
144+
context('when a $out stage is added with .addStage()', () => {
144145
it('throws a MongoAPIError', function () {
145146
expect(() => {
146147
aggregationCursor.addStage({ $out: 'test' });
147148
}).to.throw(MongoAPIError);
148149
});
149150
});
150-
context('when a $merge stage is add with .addStage()', () => {
151+
context('when a $merge stage is added with .addStage()', () => {
151152
it('throws a MongoAPIError', function () {
152153
expect(() => {
153154
aggregationCursor.addStage({ $merge: {} });
154155
}).to.throw(MongoAPIError);
155156
});
156157
});
157-
context('when a $out stage is add with .out()', () => {
158+
context('when a $out stage is added with .out()', () => {
158159
it('throws a MongoAPIError', function () {
159160
expect(() => {
160161
aggregationCursor.out('test');
@@ -198,22 +199,26 @@ describe('class AggregationCursor', () => {
198199
describe('constructor()', () => {
199200
context('when CSOT is enabled', () => {
200201
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+
});
208211
});
209212
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+
});
217222
});
218223
});
219224
});

0 commit comments

Comments
 (0)