mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
Fix tests
// FREEBIE
This commit is contained in:
parent
dcfc4701c2
commit
d0448ec778
4 changed files with 55 additions and 10 deletions
|
@ -45,6 +45,7 @@ window.assert = chai.assert;
|
|||
window.Whisper = window.Whisper || {};
|
||||
window.Whisper.Database = window.Whisper.Database || {};
|
||||
Whisper.Database.id = 'test';
|
||||
Whisper.events = _.clone(Backbone.Events);
|
||||
|
||||
/*
|
||||
* global helpers for tests
|
||||
|
|
|
@ -487,8 +487,8 @@
|
|||
|
||||
|
||||
<script type='text/x-tmpl-mustache' id='networkStatus'>
|
||||
<div class='network-status-message' style='{{^instructions}}margin-top:3px;{{/instructions}}{{#instructions}}margin-top:-6px{{/instructions}}'>
|
||||
<h3 style='{{^instructions}}font-size:17px;{{/instructions}}'>{{ message }}</h3>
|
||||
<div class='network-status-message'>
|
||||
<h3>{{ message }}</h3>
|
||||
<span>{{ instructions }}</span>
|
||||
</div>
|
||||
{{ #reconnectDurationAsSeconds }}
|
||||
|
@ -496,14 +496,21 @@
|
|||
{{ attemptingReconnectionMessage }}
|
||||
</div>
|
||||
{{/reconnectDurationAsSeconds }}
|
||||
{{ #action }}
|
||||
<div class="action">
|
||||
<button class='small blue {{ buttonClass }}'>{{ action }}</button>
|
||||
</div>
|
||||
{{/action }}
|
||||
</script>
|
||||
|
||||
|
||||
<script type="text/javascript" src="../js/components.js"></script>
|
||||
<script type="text/javascript" src="test.js"></script>
|
||||
<script type="text/javascript" src="blanket_mocha.js"></script>
|
||||
|
||||
<script type='text/javascript' src='../js/registration.js'></script>
|
||||
<script type="text/javascript" src="../js/expire.js"></script>
|
||||
<script type="text/javascript" src="../js/chromium.js"></script>
|
||||
<script type="text/javascript" src="../js/components.js"></script>
|
||||
<script type="text/javascript" src="../js/database.js"></script>
|
||||
<script type="text/javascript" src="../js/storage.js"></script>
|
||||
<script type="text/javascript" src="../js/signal_protocol_store.js"></script>
|
||||
|
@ -542,7 +549,6 @@
|
|||
<script type='text/javascript' src='../js/views/conversation_view.js' data-cover></script>
|
||||
<script type='text/javascript' src='../js/views/conversation_search_view.js' data-cover></script>
|
||||
<script type='text/javascript' src='../js/views/hint_view.js' data-cover></script>
|
||||
<script type='text/javascript' src='../js/views/network_status_view.js' data-cover></script>
|
||||
<script type='text/javascript' src='../js/views/inbox_view.js' data-cover></script>
|
||||
<script type='text/javascript' src='../js/views/network_status_view.js'></script>
|
||||
<script type='text/javascript' src='../js/views/confirmation_dialog_view.js' data-cover></script>
|
||||
|
|
|
@ -12257,6 +12257,7 @@ window.assert = chai.assert;
|
|||
window.Whisper = window.Whisper || {};
|
||||
window.Whisper.Database = window.Whisper.Database || {};
|
||||
Whisper.Database.id = 'test';
|
||||
Whisper.events = _.clone(Backbone.Events);
|
||||
|
||||
/*
|
||||
* global helpers for tests
|
||||
|
|
|
@ -11,6 +11,7 @@ describe('NetworkStatusView', function() {
|
|||
before(function() {
|
||||
oldGetSocketStatus = window.getSocketStatus;
|
||||
/* chrome i18n support is missing in 'regular' webpages */
|
||||
window.chrome = window.chrome || {};
|
||||
window.chrome.i18n = { getMessage: function(message, args) {
|
||||
// translationMessageName-arg1-arg2
|
||||
return _([message, args]).chain().flatten().compact().value().join('-');
|
||||
|
@ -41,13 +42,13 @@ describe('NetworkStatusView', function() {
|
|||
networkStatusView.navigatorOnLine = function() { return false; };
|
||||
});
|
||||
it('should be interrupted', function() {
|
||||
networkStatusView.render();
|
||||
networkStatusView.update();
|
||||
var status = networkStatusView.getNetworkStatus();
|
||||
assert(status.hasInterruption);
|
||||
assert.equal(status.instructions, "checkNetworkConnection");
|
||||
});
|
||||
it('should display an offline message', function() {
|
||||
networkStatusView.render();
|
||||
networkStatusView.update();
|
||||
assert.match(networkStatusView.$el.text(), /offline/);
|
||||
});
|
||||
it('should override socket status', function() {
|
||||
|
@ -56,15 +57,51 @@ describe('NetworkStatusView', function() {
|
|||
WebSocket.CLOSING,
|
||||
WebSocket.CLOSED]).map(function(socketStatusVal) {
|
||||
socketStatus = socketStatusVal;
|
||||
networkStatusView.render();
|
||||
networkStatusView.update();
|
||||
assert.match(networkStatusView.$el.text(), /offline/);
|
||||
});
|
||||
});
|
||||
it('should override registration status', function() {
|
||||
Whisper.Registration.remove();
|
||||
networkStatusView.update();
|
||||
assert.match(networkStatusView.$el.text(), /offline/);
|
||||
});
|
||||
});
|
||||
describe('network status when registration is not done', function() {
|
||||
beforeEach(function() {
|
||||
Whisper.Registration.remove();
|
||||
});
|
||||
it('should display an unlinked message', function() {
|
||||
networkStatusView.update();
|
||||
assert.match(networkStatusView.$el.text(), /unlinked/);
|
||||
});
|
||||
it('should override socket status', function() {
|
||||
_([WebSocket.CONNECTING,
|
||||
WebSocket.OPEN,
|
||||
WebSocket.CLOSING,
|
||||
WebSocket.CLOSED]).map(function(socketStatusVal) {
|
||||
socketStatus = socketStatusVal;
|
||||
networkStatusView.update();
|
||||
assert.match(networkStatusView.$el.text(), /unlinked/);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('network status when registration is done', function() {
|
||||
beforeEach(function() {
|
||||
networkStatusView.navigatorOnLine = function() { return true; };
|
||||
Whisper.Registration.markDone();
|
||||
networkStatusView.update();
|
||||
});
|
||||
it('should not display an unlinked message', function() {
|
||||
networkStatusView.update();
|
||||
assert.notMatch(networkStatusView.$el.text(), /unlinked/);
|
||||
});
|
||||
});
|
||||
describe('network status when socket is connecting', function() {
|
||||
beforeEach(function() {
|
||||
Whisper.Registration.markDone();
|
||||
socketStatus = WebSocket.CONNECTING;
|
||||
networkStatusView.render();
|
||||
networkStatusView.update();
|
||||
});
|
||||
it('it should display a connecting string if connecting and not in the connecting grace period', function() {
|
||||
networkStatusView.withinConnectingGracePeriod = false;
|
||||
|
@ -100,7 +137,7 @@ describe('NetworkStatusView', function() {
|
|||
_([WebSocket.CLOSED, WebSocket.CLOSING]).map(function(socketStatusVal) {
|
||||
it('should be interrupted', function() {
|
||||
socketStatus = socketStatusVal;
|
||||
networkStatusView.render();
|
||||
networkStatusView.update();
|
||||
var status = networkStatusView.getNetworkStatus();
|
||||
assert(status.hasInterruption);
|
||||
});
|
||||
|
@ -111,7 +148,7 @@ describe('NetworkStatusView', function() {
|
|||
beforeEach(function() {
|
||||
socketStatus = WebSocket.CLOSED;
|
||||
networkStatusView.setSocketReconnectInterval(61000);
|
||||
networkStatusView.render();
|
||||
networkStatusView.update();
|
||||
});
|
||||
it('should format the message based on the socketReconnectWaitDuration property', function() {
|
||||
assert.equal(networkStatusView.socketReconnectWaitDuration.asSeconds(), 61);
|
||||
|
|
Loading…
Reference in a new issue