From fe0306e6be136f90ca12e647611fba12ab5de483 Mon Sep 17 00:00:00 2001 From: colefranz Date: Sat, 3 Feb 2018 15:20:01 -0700 Subject: [PATCH 1/2] issue-2023: move opened event out of selected conversation check Going through the git history the existing logic of "dont do this if it's already selected" was just for audio or video QOL enhancements to not stop playing when the same conversation is selected. --- js/views/inbox_view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/views/inbox_view.js b/js/views/inbox_view.js index ceb3598940e1..2263577e1b11 100644 --- a/js/views/inbox_view.js +++ b/js/views/inbox_view.js @@ -28,8 +28,8 @@ $el = view.$el; } $el.prependTo(this.el); - conversation.trigger('opened'); } + conversation.trigger('opened'); }, }); From 234411cb29a6a0a89eb1a04c0c225e4def1575c7 Mon Sep 17 00:00:00 2001 From: colefranz Date: Sat, 3 Feb 2018 18:11:49 -0700 Subject: [PATCH 2/2] issue-2023: introduce unit tests for inbox view There were no unit tests for the file at all so I added some simple ones mostly focused on my changes. --- test/index.html | 1 + test/views/inbox_view_test.js | 41 +++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 test/views/inbox_view_test.js diff --git a/test/index.html b/test/index.html index 76ad1ad62326..5a8c945f4e21 100644 --- a/test/index.html +++ b/test/index.html @@ -624,6 +624,7 @@ + diff --git a/test/views/inbox_view_test.js b/test/views/inbox_view_test.js new file mode 100644 index 000000000000..341e09a45d12 --- /dev/null +++ b/test/views/inbox_view_test.js @@ -0,0 +1,41 @@ +describe('InboxView', function() { + var inboxView = new Whisper.InboxView({ + model: {}, + window: window, + initialLoadComplete: function() {} + }).render(); + + var conversation = new Whisper.Conversation({ id: '1234', type: 'private'}); + + describe('the conversation stack', function() { + it('should be rendered', function() { + assert.ok(inboxView.$('.conversation-stack').length === 1); + }); + + describe('opening a conversation', function() { + var triggeredOpenedCount = 0; + + before(function() { + conversation.on('opened', function() { + triggeredOpenedCount++; + }); + + inboxView.conversation_stack.open(conversation); + }); + + it('should trigger an opened event', function() { + assert.ok(triggeredOpenedCount === 1); + }); + + describe('and then opening it again immediately', function() { + before(function() { + inboxView.conversation_stack.open(conversation); + }); + + it('should trigger the opened event again', function() { + assert.ok(triggeredOpenedCount === 2); + }); + }); + }); + }); +});