diff --git a/frontend_tests/node_tests/search_suggestion.js b/frontend_tests/node_tests/search_suggestion.js index ada2ad3773..9a62031f8d 100644 --- a/frontend_tests/node_tests/search_suggestion.js +++ b/frontend_tests/node_tests/search_suggestion.js @@ -432,16 +432,29 @@ init(); return 'office'; }; - global.stream_data.populate_stream_topics_for_tests({ - devel: [ - {subject: 'REXX'}, - ], - office: [ - {subject: 'team'}, - {subject: 'ignore'}, - {subject: 'test'}, - ], - }); + var devel_id = 44; + var office_id = 77; + + global.stream_data.get_stream_id = function (stream_name) { + switch (stream_name) { + case 'office': return office_id; + case 'devel': return devel_id; + } + }; + + var recent_data = {}; + + recent_data[devel_id] = [ + {subject: 'REXX'}, + ]; + + recent_data[office_id] = [ + {subject: 'team'}, + {subject: 'ignore'}, + {subject: 'test'}, + ]; + + global.stream_data.populate_stream_topics_for_tests(recent_data); suggestions = search.get_suggestions('te'); expected = [ diff --git a/frontend_tests/node_tests/stream_data.js b/frontend_tests/node_tests/stream_data.js index bf24b6eb49..f7dc89f35e 100644 --- a/frontend_tests/node_tests/stream_data.js +++ b/frontend_tests/node_tests/stream_data.js @@ -240,8 +240,17 @@ var people = global.people; }()); (function test_process_message_for_recent_topics() { + var stream_id = 55; + + var rome = { + name: 'Rome', + stream_id: stream_id, + }; + + stream_data.add_sub('Rome', rome); + var message = { - stream: 'Rome', + stream_id: stream_id, timestamp: 101, subject: 'toPic1', }; @@ -258,7 +267,7 @@ var people = global.people; ]); message = { - stream: 'Rome', + stream_id: stream_id, timestamp: 102, subject: 'Topic1', }; @@ -274,7 +283,7 @@ var people = global.people; ]); message = { - stream: 'Rome', + stream_id: stream_id, timestamp: 103, subject: 'topic2', }; @@ -321,13 +330,13 @@ var people = global.people; stream_data.unsubscribe_myself(sub); assert(!stream_data.is_active(sub)); - sub = {name: 'lunch', subscribed: false, stream_id: 1}; + sub = {name: 'lunch', subscribed: false, stream_id: 222}; stream_data.add_sub('lunch', sub); assert(!stream_data.is_active(sub)); var message = { - stream: 'lunch', + stream_id: 222, timestamp: 108, subject: 'topic2', }; diff --git a/frontend_tests/node_tests/topic_list.js b/frontend_tests/node_tests/topic_list.js index 9963681ac4..fc4e2caadb 100644 --- a/frontend_tests/node_tests/topic_list.js +++ b/frontend_tests/node_tests/topic_list.js @@ -19,19 +19,21 @@ var topic_list = require('js/topic_list.js'); global.compile_template('topic_list_item'); (function test_topic_list_build_widget() { + var stream_id = 555; var stream = "devel"; var active_topic = "testing"; var max_topics = 5; - var topics = [ + var recent_topics = {}; + recent_topics[stream_id] = [ {subject: "coding"}, ]; - global.stream_data.populate_stream_topics_for_tests({devel: topics}); + global.stream_data.populate_stream_topics_for_tests(recent_topics); global.unread.num_unread_for_subject = function () { return 1; }; - global.stream_data.get_stream_id = function () { return 99; }; + global.stream_data.get_stream_id = function () { return stream_id; }; var parent_elem = $('