Skip to content

Commit b0ac290

Browse files
committed
test: fix assertion order
1 parent 9915ec9 commit b0ac290

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/change_stream.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -731,11 +731,7 @@ export class ChangeStream<
731731
return;
732732
}
733733

734-
while (true) {
735-
if (!(await this.hasNext())) {
736-
break;
737-
}
738-
734+
while (await this.hasNext()) {
739735
yield await this.next();
740736
}
741737
}

test/integration/change-streams/change_stream.test.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -2139,7 +2139,7 @@ describe('ChangeStream resumability', function () {
21392139
});
21402140
});
21412141

2142-
context.only('#asyncIterator', function () {
2142+
context('#asyncIterator', function () {
21432143
for (const { error, code, message } of resumableErrorCodes) {
21442144
it(
21452145
`resumes on error code ${code} (${error})`,
@@ -2280,7 +2280,7 @@ describe('ChangeStream resumability', function () {
22802280
);
22812281

22822282
context('when the error is not a resumable error', function () {
2283-
it(
2283+
it.only(
22842284
'does not resume',
22852285
{ requires: { topology: '!single', mongodb: '>=4.2' } },
22862286
async function () {
@@ -2303,15 +2303,16 @@ describe('ChangeStream resumability', function () {
23032303
await collection.insertOne({ city: 'New York City' });
23042304
try {
23052305
for await (const change of changeStream) {
2306-
// DOESN'T REACH
23072306
expect.fail('Change stream produced changes on an unresumable error');
23082307
}
2308+
2309+
expect.fail(
2310+
'Change stream did not throw unresumable error and did not produce any events'
2311+
);
23092312
} catch (error) {
23102313
expect(error).to.be.instanceOf(MongoServerError);
23112314
expect(aggregateEvents).to.have.lengthOf(1);
23122315
}
2313-
// fails here
2314-
expect.fail('Change stream did not throw unresumable error');
23152316
}
23162317
);
23172318
});

0 commit comments

Comments
 (0)