Skip to content

Commit baab5e8

Browse files
committed
test: fix assertion order
1 parent d5bbdd8 commit baab5e8

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
@@ -732,11 +732,7 @@ export class ChangeStream<
732732
return;
733733
}
734734

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

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)