From 6c262f721399edfedd4b2ef7fb509a1c0a02249e Mon Sep 17 00:00:00 2001 From: JC Brand Date: Wed, 14 Jun 2017 20:14:45 +0200 Subject: [PATCH] Various small changes to reduce (non-critical) errors during testing --- spec/converse.js | 5 ++++- src/converse-minimize.js | 6 +++++- src/converse-muc.js | 2 +- tests/mock.js | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/spec/converse.js b/spec/converse.js index 377a3020a..709200733 100644 --- a/spec/converse.js +++ b/spec/converse.js @@ -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); diff --git a/src/converse-minimize.js b/src/converse-minimize.js index c9638b8cd..aef1cb604 100644 --- a/src/converse-minimize.js +++ b/src/converse-minimize.js @@ -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); diff --git a/src/converse-muc.js b/src/converse-muc.js index 553274f59..1c653aeb3 100755 --- a/src/converse-muc.js +++ b/src/converse-muc.js @@ -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(); diff --git a/tests/mock.js b/tests/mock.js index 532a59bd4..1a9e1d18f 100644 --- a/tests/mock.js +++ b/tests/mock.js @@ -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,