Instead of stubbing `dispatchEvent`, we can use `window.addEventListener('bluetoothconnectionchange')` directly since `bluetoothconnectionchange` is an ordinary DOM event. The we can test if `event.detail.deviceConnected` equals true in the handler.