tests: Fully cover top_left_corner.js.

This commit is contained in:
Joshua Pan 2018-04-17 23:48:31 -07:00 committed by showell
parent 09469026c6
commit 99f07fe2e2
2 changed files with 21 additions and 3 deletions

View File

@ -5,13 +5,14 @@ zrequire('unread_ui');
zrequire('top_left_corner');
var noop = function () {};
(function test_narrowing() {
// activating narrow
var pm_expanded;
var pm_closed;
set_global('pm_list', {
close: noop,
close: function () { pm_closed = true; },
expand: function () { pm_expanded = true; },
});
@ -33,6 +34,17 @@ var noop = function () {};
]);
top_left_corner.handle_narrow_activated(filter);
assert(top_left_corner.get_global_filter_li('home').hasClass('active-filter'));
// deactivating narrow
pm_closed = false;
top_left_corner.handle_narrow_deactivated();
assert(top_left_corner.get_global_filter_li('home').hasClass('active-filter'));
assert(!top_left_corner.get_global_filter_li('mentioned').hasClass('active-filter'));
assert(!top_left_corner.get_global_filter_li('private').hasClass('active-filter'));
assert(!top_left_corner.get_global_filter_li('starred').hasClass('active-filter'));
assert(pm_closed);
}());
(function test_update_count_in_dom() {
@ -69,4 +81,9 @@ var noop = function () {};
assert.equal($('<mentioned-value>').text(), '222');
assert.equal($('<home-value>').text(), '333');
counts.mentioned_message_count = 0;
top_left_corner.update_dom_with_unread_counts(counts);
assert(!$('<mentioned-count>').visible());
assert.equal($('<mentioned-value>').text(), '');
}());

View File

@ -60,6 +60,7 @@ enforce_fully_covered = {
'static/js/stream_data.js',
'static/js/stream_events.js',
'static/js/stream_sort.js',
'static/js/top_left_corner.js',
'static/js/topic_data.js',
'static/js/topic_generator.js',
'static/js/transmit.js',