From a4e2ed9fd2dbcba50ba79eeb77a44737419bc782 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Wed, 18 Sep 2013 13:14:08 -0400 Subject: [PATCH] Add test_narrowed() to narrow.js unit tests. (imported from commit 060032ac00d0c28a9625e2885ee3156bc94ff130) --- zerver/tests/frontend/node/narrow.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/zerver/tests/frontend/node/narrow.js b/zerver/tests/frontend/node/narrow.js index af31e83e48..a360dae604 100644 --- a/zerver/tests/frontend/node/narrow.js +++ b/zerver/tests/frontend/node/narrow.js @@ -21,6 +21,34 @@ function set_filter(operators) { 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() { set_filter([['stream', 'Foo'], ['topic', 'Bar'], ['search', 'Yo']]); var canonical_operators = [['stream', 'Foo'], ['topic', 'Bar'], ['search', 'yo']];