From d1e1e69abe721d283c25f491821b2af6308af1b8 Mon Sep 17 00:00:00 2001 From: Cory Lynch Date: Wed, 7 Jun 2017 00:30:18 -0400 Subject: [PATCH] message_list: Add tests for message_range. --- frontend_tests/node_tests/message_list.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/frontend_tests/node_tests/message_list.js b/frontend_tests/node_tests/message_list.js index b5dbc52e03..6b59c44817 100644 --- a/frontend_tests/node_tests/message_list.js +++ b/frontend_tests/node_tests/message_list.js @@ -117,6 +117,20 @@ var MessageList = require('js/message_list').MessageList; assert.deepEqual(list.all_messages(), []); }()); +(function test_message_range() { + var table; + var filter = {}; + var list = new MessageList(table, filter); + + var messages = [{id: 30}, {id: 40}, {id: 50}, {id: 60}]; + list.append(messages, true); + assert.deepEqual(list.message_range(2, 30), [{id: 30}]); + assert.deepEqual(list.message_range(2, 31), [{id: 30}, {id: 40}]); + assert.deepEqual(list.message_range(30, 40), [{id: 30}, {id: 40}]); + assert.deepEqual(list.message_range(31, 39), [{id: 40}]); + assert.deepEqual(list.message_range(31, 1000), [{id: 40}, {id: 50}, {id: 60}]); +}()); + (function test_nth_most_recent_id() { var table; var filter = {};