2016-11-05 16:36:30 +01:00
|
|
|
add_dependencies({
|
|
|
|
Handlebars: 'handlebars',
|
|
|
|
hashchange: 'js/hashchange',
|
|
|
|
muting: 'js/muting',
|
|
|
|
narrow: 'js/narrow',
|
|
|
|
stream_data: 'js/stream_data',
|
|
|
|
templates: 'js/templates'
|
|
|
|
});
|
|
|
|
|
|
|
|
set_global('unread', {});
|
|
|
|
|
|
|
|
var jsdom = require("jsdom");
|
|
|
|
var window = jsdom.jsdom().defaultView;
|
|
|
|
global.$ = require('jquery')(window);
|
|
|
|
|
|
|
|
var topic_list = require('js/topic_list.js');
|
|
|
|
|
|
|
|
global.compile_template('topic_list_item');
|
|
|
|
|
|
|
|
(function test_topic_list_build_widget() {
|
|
|
|
var stream = "devel";
|
|
|
|
var active_topic = "testing";
|
|
|
|
var max_topics = 5;
|
|
|
|
|
|
|
|
var topics = [
|
|
|
|
{subject: "coding"}
|
|
|
|
];
|
|
|
|
global.stream_data.populate_stream_topics_for_tests({"devel": topics});
|
|
|
|
global.unread.num_unread_for_subject = function () {
|
|
|
|
return 1;
|
|
|
|
};
|
|
|
|
|
2016-11-10 20:05:14 +01:00
|
|
|
var parent_elem = $('<div>');
|
|
|
|
var widget = topic_list.build_widget(parent_elem, stream, active_topic, max_topics);
|
2016-11-05 16:36:30 +01:00
|
|
|
var topic_html = widget.get_dom();
|
|
|
|
|
2016-11-10 20:05:14 +01:00
|
|
|
assert.equal(widget.get_parent(), parent_elem);
|
2016-11-10 20:19:22 +01:00
|
|
|
assert.equal(widget.get_stream_name(), 'devel');
|
2016-11-10 20:05:14 +01:00
|
|
|
|
2016-11-05 16:36:30 +01:00
|
|
|
var topic = $(topic_html).find('a').text().trim();
|
|
|
|
assert.equal(topic, 'coding');
|
2016-11-05 16:54:57 +01:00
|
|
|
|
2016-11-10 20:05:14 +01:00
|
|
|
global.write_test_output("test_topic_list_build_widget", parent_elem.html());
|
2016-11-05 16:36:30 +01:00
|
|
|
}());
|
|
|
|
|