Skip to content

Commit

Permalink
fix(test): do not listen connect event
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximoLiberata committed Aug 3, 2024
1 parent 0e9edea commit 2dc39f2
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions test/abstract_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2128,6 +2128,19 @@ export default function abstractTest(server, config, ports) {
reschedulePings,
})

// Just in case `connect` event is emmited before setting up the other listeners
// move `connect` event at the top
client.once('connect', () => {
// Prevent publishing before setting up the listeners
process.nextTick(() => {
// reset call count (it's called also on connack)
spyReschedule.resetHistory()
// use qos1 so the puback is received (to reschedule ping)
client.publish('foo', 'bar', { qos: 1 })
client.publish('foo', 'bar', { qos: 1 })
}, 1)
})

const spyReschedule = sinon.spy(
client,
'_reschedulePing' as any,
Expand Down Expand Up @@ -2169,13 +2182,8 @@ export default function abstractTest(server, config, ports) {
})
})

client.once('connect', () => {
// reset call count (it's called also on connack)
spyReschedule.resetHistory()
// use qos1 so the puback is received (to reschedule ping)
client.publish('foo', 'bar', { qos: 1 })
client.publish('foo', 'bar', { qos: 1 })
})
// After setting up the listeners, publish the packages
clock.tick(1)
})
}

Expand Down

0 comments on commit 2dc39f2

Please sign in to comment.