Skip to content

Commit

Permalink
test: remove duplicate event listeners and check known events
Browse files Browse the repository at this point in the history
  • Loading branch information
dariakp committed Aug 12, 2022
1 parent 8ec6dcb commit 93060c5
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions test/tools/unified-spec-runner/entities.ts
Expand Up @@ -119,15 +119,16 @@ export class UnifiedMongoClient extends MongoClient {
'configureFailPoint'
];

this.observedEvents = (description.observeEvents ?? [])
.map(e => UnifiedMongoClient.EVENT_NAME_LOOKUP[e])
.filter(e => !!e);
this.observedEvents = (description.observeEvents ?? [])
.map(e => UnifiedMongoClient.EVENT_NAME_LOOKUP[e])
.filter(e => !!e);
for (const eventName of this.observedEvents) {
this.on(eventName, this.pushEvent);
this.observedEvents = [];

for (const e of description.observeEvents ?? []) {
const eventToObserve = UnifiedMongoClient.EVENT_NAME_LOOKUP[e];
if (!eventToObserve) {
throw new Error(`Unknown expected event: ${e}`);
}
this.observedEvents.push(eventToObserve);
}

for (const eventName of this.observedEvents) {
this.on(eventName, this.pushEvent);
}
Expand Down

0 comments on commit 93060c5

Please sign in to comment.