Fix tests
This commit is contained in:
parent
7dd155eb16
commit
ccfc9046b4
|
@ -46,7 +46,7 @@
|
|||
getSocketStatus() {
|
||||
return window.getSocketStatus();
|
||||
},
|
||||
getNetworkStatus() {
|
||||
getNetworkStatus(shortCircuit = false) {
|
||||
let message = '';
|
||||
let instructions = '';
|
||||
let hasInterruption = false;
|
||||
|
@ -67,26 +67,28 @@
|
|||
this.connectedTimer = null;
|
||||
break;
|
||||
case WebSocket.CLOSED:
|
||||
if (!this.connectedTimer) {
|
||||
// Mark offline if disconnected for 30 seconds
|
||||
this.connectedTimer = window.setTimeout(() => {
|
||||
message = i18n('disconnected');
|
||||
instructions = i18n('checkNetworkConnection');
|
||||
hasInterruption = true;
|
||||
}, DISCONNECTED_DELAY);
|
||||
}
|
||||
break;
|
||||
// Intentional fallthrough
|
||||
case WebSocket.CLOSING:
|
||||
default:
|
||||
// Intentional fallthrough
|
||||
default: {
|
||||
const markOffline = () => {
|
||||
message = i18n('disconnected');
|
||||
instructions = i18n('checkNetworkConnection');
|
||||
hasInterruption = true;
|
||||
};
|
||||
if (shortCircuit) {
|
||||
// Used to skip the timer for testing
|
||||
markOffline();
|
||||
break;
|
||||
}
|
||||
if (!this.connectedTimer) {
|
||||
// Mark offline if disconnected for 30 seconds
|
||||
this.connectedTimer = window.setTimeout(() => {
|
||||
message = i18n('disconnected');
|
||||
instructions = i18n('checkNetworkConnection');
|
||||
hasInterruption = true;
|
||||
markOffline();
|
||||
}, DISCONNECTED_DELAY);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
|
|
|
@ -153,7 +153,8 @@ describe('NetworkStatusView', () => {
|
|||
it('should be interrupted', () => {
|
||||
socketStatus = socketStatusVal;
|
||||
networkStatusView.update();
|
||||
const status = networkStatusView.getNetworkStatus();
|
||||
const shortCircuit = true;
|
||||
const status = networkStatusView.getNetworkStatus(shortCircuit);
|
||||
assert(status.hasInterruption);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue