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.stream_data = require('js/stream_data.js');
    global.Filter = require('js/filter.js');
}());

var narrow = global.narrow;
var Filter = global.Filter;

(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 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 Filter(operators));

    assert.deepEqual(narrow.operators(), canonical_operators);
}());

@@ -1246,16 +1246,313 @@
 erators);%0A%7D());%0A
+%0A(function test_set_compose_defaults() %7B%0A    var operators = %5B%5B'stream', 'Foo'%5D, %5B'topic', 'Bar'%5D%5D;%0A    narrow._set_current_filter(new Filter(operators));%0A%0A    var opts = %7B%7D;%0A    narrow.set_compose_defaults(opts);%0A    assert.equal(opts.stream, 'foo');%0A    assert.equal(opts.subject, 'bar');%0A%7D());%0A

Add unit test for narrow.set_compose_defaults().