2017-01-19 03:53:50 +01:00
|
|
|
add_dependencies({
|
2017-03-19 00:43:14 +01:00
|
|
|
hash_util: 'js/hash_util.js',
|
2017-01-19 03:53:50 +01:00
|
|
|
people: 'js/people.js',
|
|
|
|
});
|
|
|
|
|
2014-02-19 22:19:16 +01:00
|
|
|
var hashchange = require('js/hashchange.js');
|
|
|
|
|
2017-03-18 18:29:20 +01:00
|
|
|
|
2017-01-05 22:04:33 +01:00
|
|
|
(function test_operators_round_trip() {
|
2014-02-19 22:19:16 +01:00
|
|
|
var operators;
|
|
|
|
var hash;
|
2017-01-05 22:04:33 +01:00
|
|
|
var narrow;
|
2014-02-19 22:19:16 +01:00
|
|
|
|
|
|
|
operators = [
|
|
|
|
{operator: 'stream', operand: 'devel'},
|
2016-12-03 23:17:57 +01:00
|
|
|
{operator: 'topic', operand: 'algol'},
|
2014-02-19 22:19:16 +01:00
|
|
|
];
|
|
|
|
hash = hashchange.operators_to_hash(operators);
|
|
|
|
assert.equal(hash, '#narrow/stream/devel/topic/algol');
|
|
|
|
|
2017-01-05 22:04:33 +01:00
|
|
|
narrow = hashchange.parse_narrow(hash.split('/'));
|
|
|
|
assert.deepEqual(narrow, [
|
|
|
|
{operator: 'stream', operand: 'devel', negated: false},
|
|
|
|
{operator: 'topic', operand: 'algol', negated: false},
|
|
|
|
]);
|
|
|
|
|
2014-02-19 22:19:16 +01:00
|
|
|
operators = [
|
|
|
|
{operator: 'stream', operand: 'devel'},
|
2016-12-03 23:17:57 +01:00
|
|
|
{operator: 'topic', operand: 'visual c++', negated: true},
|
2014-02-19 22:19:16 +01:00
|
|
|
];
|
|
|
|
hash = hashchange.operators_to_hash(operators);
|
|
|
|
assert.equal(hash, '#narrow/stream/devel/-topic/visual.20c.2B.2B');
|
2017-01-05 22:04:33 +01:00
|
|
|
|
|
|
|
narrow = hashchange.parse_narrow(hash.split('/'));
|
|
|
|
assert.deepEqual(narrow, [
|
|
|
|
{operator: 'stream', operand: 'devel', negated: false},
|
|
|
|
{operator: 'topic', operand: 'visual c++', negated: true},
|
|
|
|
]);
|
|
|
|
|
2014-02-19 22:19:16 +01:00
|
|
|
}());
|
2017-01-19 03:53:50 +01:00
|
|
|
|
|
|
|
(function test_people_slugs() {
|
|
|
|
var operators;
|
|
|
|
var hash;
|
|
|
|
var narrow;
|
|
|
|
|
|
|
|
var alice = {
|
|
|
|
email: 'alice@example.com',
|
|
|
|
user_id: 42,
|
|
|
|
full_name: 'Alice Smith',
|
|
|
|
};
|
|
|
|
|
|
|
|
people.add(alice);
|
|
|
|
operators = [
|
|
|
|
{operator: 'sender', operand: 'alice@example.com'},
|
|
|
|
];
|
|
|
|
hash = hashchange.operators_to_hash(operators);
|
|
|
|
assert.equal(hash, '#narrow/sender/42-alice');
|
|
|
|
narrow = hashchange.parse_narrow(hash.split('/'));
|
|
|
|
assert.deepEqual(narrow, [
|
|
|
|
{operator: 'sender', operand: 'alice@example.com', negated: false},
|
|
|
|
]);
|
|
|
|
|
|
|
|
operators = [
|
|
|
|
{operator: 'pm-with', operand: 'alice@example.com'},
|
|
|
|
];
|
|
|
|
hash = hashchange.operators_to_hash(operators);
|
|
|
|
assert.equal(hash, '#narrow/pm-with/42-alice');
|
|
|
|
}());
|