From 12d1086d14aa8338b9d7f881c6445afe65e8d13a Mon Sep 17 00:00:00 2001 From: Cory Lynch Date: Wed, 7 Jun 2017 02:11:01 -0400 Subject: [PATCH] message_list: Add tests for sent_by_me. --- frontend_tests/node_tests/message_list.js | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/frontend_tests/node_tests/message_list.js b/frontend_tests/node_tests/message_list.js index 09c6c7a346..2716260c49 100644 --- a/frontend_tests/node_tests/message_list.js +++ b/frontend_tests/node_tests/message_list.js @@ -195,6 +195,32 @@ var MessageList = require('js/message_list').MessageList; assert.equal(list.get(10).content, "ok!"); }()); +(function test_last_sent_by_me() { + var table; + var filter = {}; + + var list = new MessageList(table, filter); + var items = [ + { + id: 1, + sender_id: 3, + }, + { + id: 2, + sender_id: 3, + }, + { + id: 3, + sender_id: 6, + }, + ]; + + list.append(items); + set_global("page_params", {user_id: 3}); + // Look for the last message where user_id == 3 (our ID) + assert.equal(list.get_last_message_sent_by_me().id, 2); +}()); + (function test_local_echo() { var table; var filter = {};