Skip to content

Commit bcc57d6

Browse files
authored
test(NODE-3801): fix explain tests to work with latest server (#3065)
1 parent 0d80847 commit bcc57d6

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

test/functional/explain.test.js

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -645,10 +645,9 @@ describe('Explain', function () {
645645
.aggregate([{ $project: { a: 1 } }, { $group: { _id: '$a' } }], { explain: true })
646646
.toArray((err, docs) => {
647647
expect(err).to.not.exist;
648-
const result = docs[0];
649-
expect(result).to.have.property('stages');
650-
expect(result.stages).to.have.lengthOf.at.least(1);
651-
expect(result.stages[0]).to.have.property('$cursor');
648+
const result = JSON.stringify(docs[0]);
649+
expect(result).to.include('"queryPlanner"');
650+
expect(result).to.include('"executionStats"');
652651
done();
653652
});
654653
});
@@ -675,12 +674,9 @@ describe('Explain', function () {
675674
})
676675
.toArray((err, docs) => {
677676
expect(err).to.not.exist;
678-
const result = docs[0];
679-
expect(result).to.have.property('stages');
680-
expect(result.stages).to.have.lengthOf.at.least(1);
681-
expect(result.stages[0]).to.have.property('$cursor');
682-
expect(result.stages[0].$cursor).to.have.property('queryPlanner');
683-
expect(result.stages[0].$cursor).to.have.property('executionStats');
677+
const result = JSON.stringify(docs[0]);
678+
expect(result).to.include('"queryPlanner"');
679+
expect(result).to.include('"executionStats"');
684680
done();
685681
});
686682
});
@@ -699,11 +695,11 @@ describe('Explain', function () {
699695

700696
collection
701697
.aggregate([{ $project: { a: 1 } }, { $group: { _id: '$a' } }])
702-
.explain(false, (err, result) => {
698+
.explain(false, (err, res) => {
703699
expect(err).to.not.exist;
704-
expect(result).to.have.property('stages');
705-
expect(result.stages).to.have.lengthOf.at.least(1);
706-
expect(result.stages[0]).to.have.property('$cursor');
700+
const result = JSON.stringify(res);
701+
expect(result).to.include('"queryPlanner"');
702+
expect(result).not.to.include('"executionStats"');
707703
done();
708704
});
709705
});
@@ -726,14 +722,12 @@ describe('Explain', function () {
726722

727723
collection
728724
.aggregate([{ $project: { a: 1 } }, { $group: { _id: '$a' } }])
729-
.explain('allPlansExecution', (err, result) => {
725+
.explain('allPlansExecution', (err, res) => {
730726
expect(err).to.not.exist;
731-
expect(result).to.exist;
732-
expect(result).to.have.property('stages');
733-
expect(result.stages).to.have.lengthOf.at.least(1);
734-
expect(result.stages[0]).to.have.property('$cursor');
735-
expect(result.stages[0].$cursor).to.have.property('queryPlanner');
736-
expect(result.stages[0].$cursor).to.have.property('executionStats');
727+
expect(res).to.exist;
728+
const result = JSON.stringify(res);
729+
expect(result).to.include('"queryPlanner"');
730+
expect(result).to.include('"executionStats"');
737731
done();
738732
});
739733
});
@@ -752,11 +746,11 @@ describe('Explain', function () {
752746

753747
collection
754748
.aggregate([{ $project: { a: 1 } }, { $group: { _id: '$a' } }])
755-
.explain((err, result) => {
749+
.explain((err, res) => {
756750
expect(err).to.not.exist;
757-
expect(result).to.have.property('stages');
758-
expect(result.stages).to.have.lengthOf.at.least(1);
759-
expect(result.stages[0]).to.have.property('$cursor');
751+
const result = JSON.stringify(res);
752+
expect(result).to.include('"queryPlanner"');
753+
expect(result).to.include('"executionStats"');
760754
done();
761755
});
762756
});

0 commit comments

Comments
 (0)