Skip to content

Commit 9801ad1

Browse files
committed
fix: unit test assertions, props always present
1 parent c27b721 commit 9801ad1

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

test/unit/assorted/server_discovery_and_monitoring.spec.test.ts

+6-22
Original file line numberDiff line numberDiff line change
@@ -493,37 +493,21 @@ function assertTopologyDescriptionOutcomeExpectations(
493493
}
494494
}
495495

496-
if (outcome.setName != null) {
497-
expect(description).to.have.property('setName', outcome.setName);
498-
} else {
499-
expect(description).to.not.have.property('setName');
500-
}
501-
502-
if (outcome.maxSetVersion != null) {
503-
expect(description).to.have.property('maxSetVersion', outcome.maxSetVersion);
504-
} else {
505-
expect(description).to.not.have.property('maxSetVersion');
506-
}
507-
508496
if (outcome.maxElectionId != null) {
509497
expect(description).to.have.property('maxElectionId').that.is.instanceOf(ObjectId);
510-
const driverMaxId = description.maxElectionId.toString('hex');
498+
const driverMaxId = description.maxElectionId?.toString('hex');
511499
const testMaxId = outcome.maxElectionId.toString('hex');
512500
// Much easier to debug a hex string mismatch
513501
expect(driverMaxId).to.equal(testMaxId);
514502
} else {
515-
expect(description).to.not.have.property('maxElectionId');
516-
}
517-
518-
if (outcome.compatible != null) {
519-
expect(description).to.have.property('compatible', outcome.compatible);
520-
} else {
521-
expect(description).to.have.property('compatible', true);
503+
expect(description).to.have.property('maxElectionId', null);
522504
}
523505

524-
// logicalSessionTimeoutMinutes is always defined
506+
expect(description).to.have.property('setName', outcome.setName ?? null);
507+
expect(description).to.have.property('maxSetVersion', outcome.maxSetVersion ?? null);
508+
expect(description).to.have.property('compatible', outcome.compatible ?? true);
525509
expect(description).to.have.property(
526510
'logicalSessionTimeoutMinutes',
527-
outcome.logicalSessionTimeoutMinutes ?? undefined
511+
outcome.logicalSessionTimeoutMinutes ?? null
528512
);
529513
}

0 commit comments

Comments
 (0)