Various small changes to reduce (non-critical) errors during testing

This commit is contained in:
JC Brand 2017-06-14 20:14:45 +02:00
parent b0c20d5473
commit 6c262f7213
4 changed files with 11 additions and 3 deletions

View File

@ -321,7 +321,10 @@
});
describe("The \"settings\" API", function() {
it("has methods 'get' and 'set' to set configuration settings", mock.initConverse(function (_converse) {
it("has methods 'get' and 'set' to set configuration settings", mock.initConverse(
{'play_sounds': true},
function (_converse) {
expect(_.keys(_converse.api.settings)).toEqual(["get", "set"]);
expect(_converse.api.settings.get("play_sounds")).toBe(true);
_converse.api.settings.set("play_sounds", false);

View File

@ -150,7 +150,11 @@
var _converse = this.__super__._converse;
if (ev && ev.preventDefault) { ev.preventDefault(); }
// save the scroll position to restore it on maximize
this.model.save({'scroll': this.$content.scrollTop()});
if (this.model.collection && this.model.collection.browserStorage) {
this.model.save({'scroll': this.$content.scrollTop()});
} else {
this.model.set({'scroll': this.$content.scrollTop()});
}
this.setChatState(_converse.INACTIVE).model.minimize();
this.hide();
_converse.emit('chatBoxMinimized', this);

View File

@ -548,7 +548,7 @@
*
* This is instead done in `afterConnected` below.
*/
if (this.model.collection.browserStorage) {
if (this.model.collection && this.model.collection.browserStorage) {
// Without a connection, we haven't yet initialized
// localstorage
this.model.save();

View File

@ -90,6 +90,7 @@
var converse = converse_api.initialize(_.extend({
'i18n': 'en',
'auto_subscribe': false,
'play_sounds': false,
'bosh_service_url': 'localhost',
'connection': connection,
'animate': false,