Add test_narrowed() to narrow.js unit tests.

(imported from commit 060032ac00d0c28a9625e2885ee3156bc94ff130)
This commit is contained in:
Steve Howell 2013-09-18 13:14:08 -04:00
parent 51b8caf442
commit a4e2ed9fd2
1 changed files with 28 additions and 0 deletions

View File

@ -21,6 +21,34 @@ function set_filter(operators) {
assert.equal(narrow.stream(), 'Foo'); assert.equal(narrow.stream(), 'Foo');
}()); }());
(function test_narrowed() {
narrow._set_current_filter(undefined); // not narrowed, basically
assert(!narrow.narrowed_to_pms());
assert(!narrow.narrowed_by_reply());
assert(!narrow.narrowed_to_search());
set_filter([['stream', 'Foo']]);
assert(!narrow.narrowed_to_pms());
assert(!narrow.narrowed_by_reply());
assert(!narrow.narrowed_to_search());
set_filter([['pm-with', 'steve@zulip.com']]);
assert(narrow.narrowed_to_pms());
assert(narrow.narrowed_by_reply());
assert(!narrow.narrowed_to_search());
set_filter([['stream', 'Foo'], ['topic', 'bar']]);
assert(!narrow.narrowed_to_pms());
assert(narrow.narrowed_by_reply());
assert(!narrow.narrowed_to_search());
set_filter([['search', 'grail']]);
assert(!narrow.narrowed_to_pms());
assert(!narrow.narrowed_by_reply());
assert(narrow.narrowed_to_search());
}());
(function test_operators() { (function test_operators() {
set_filter([['stream', 'Foo'], ['topic', 'Bar'], ['search', 'Yo']]); set_filter([['stream', 'Foo'], ['topic', 'Bar'], ['search', 'Yo']]);
var canonical_operators = [['stream', 'Foo'], ['topic', 'Bar'], ['search', 'yo']]; var canonical_operators = [['stream', 'Foo'], ['topic', 'Bar'], ['search', 'yo']];