mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	There are also one or two places we don't need to use it for security purposes, but we do so for consistencey. (imported from commit aa111f5a22a0e8597ec3cf8504adae66d5fb6768)
		
			
				
	
	
		
			38 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
var assert = require('assert');
 | 
						|
 | 
						|
(function set_up_dependencies () {
 | 
						|
    global._ = require('third/underscore/underscore.js');
 | 
						|
    global.util = require('js/util.js');
 | 
						|
    global.Dict = require('js/dict.js');
 | 
						|
    global.narrow = require('js/narrow.js');
 | 
						|
    global.$ = function () {}; // for subs.js
 | 
						|
    global.subs = require('js/subs.js');
 | 
						|
}());
 | 
						|
 | 
						|
var narrow = global.narrow;
 | 
						|
 | 
						|
(function test_parse_and_unparse() {
 | 
						|
    var string ='stream:Foo topic:Bar yo';
 | 
						|
    var operators = [['stream', 'Foo'], ['topic', 'Bar'], ['search', 'yo']];
 | 
						|
 | 
						|
    assert.deepEqual(narrow.parse(string), operators);
 | 
						|
 | 
						|
    string = 'stream:foo topic:bar yo';
 | 
						|
    assert.deepEqual(narrow.unparse(operators), string);
 | 
						|
}());
 | 
						|
 | 
						|
(function test_stream() {
 | 
						|
    var operators = [['stream', 'Foo'], ['topic', 'Bar'], ['search', 'yo']];
 | 
						|
    narrow._set_current_filter(new narrow.Filter(operators));
 | 
						|
 | 
						|
    assert.equal(narrow.stream(), 'foo');
 | 
						|
}());
 | 
						|
 | 
						|
(function test_operators() {
 | 
						|
    var operators = [['stream', 'Foo'], ['topic', 'Bar'], ['search', 'yo']];
 | 
						|
    var canonical_operators = [['stream', 'foo'], ['topic', 'bar'], ['search', 'yo']];
 | 
						|
    narrow._set_current_filter(new narrow.Filter(operators));
 | 
						|
 | 
						|
    assert.deepEqual(narrow.operators(), canonical_operators);
 | 
						|
}());
 |