tests: Fully cover hash_util.js.

This commit is contained in:
Joshua Pan
2018-08-04 16:30:23 -07:00
committed by Tim Abbott
parent 3a74df17de
commit 5303281dfb
2 changed files with 34 additions and 0 deletions

View File

@@ -2,6 +2,16 @@ zrequire('hash_util');
zrequire('stream_data');
zrequire('people');
var _window = {
location: {
protocol: "https:",
host: "example.com",
pathname: "/",
},
};
global.patch_builtin('window', _window);
var hamlet = {
user_id: 1,
email: 'hamlet@example.com',
@@ -52,3 +62,26 @@ run_test('hash_util', () => {
encode_decode_operand(operator, operand, 'testing.20123');
});
run_test('test_by_conversation_and_time_uri', () => {
var message = {
type: 'stream',
stream: 'frontend',
subject: 'testing',
id: 42,
};
assert.equal(hash_util.by_conversation_and_time_uri(message),
'https://example.com/#narrow/stream/99-frontend/subject/testing/near/42');
message = {
type: 'private',
reply_to: 'iago@example.com,hamlet@example.com',
id: 43,
};
people.my_current_email = () => 'jeff@example.com';
assert.equal(hash_util.by_conversation_and_time_uri(message),
'https://example.com/#narrow/pm-with/iago.40example.2Ecom.2Chamlet.40example.2Ecom.2Cjeff.40example.2Ecom/near/43');
});

View File

@@ -43,6 +43,7 @@ enforce_fully_covered = {
'static/js/fenced_code.js',
'static/js/fetch_status.js',
'static/js/filter.js',
'static/js/hash_util.js',
'static/js/keydown_util.js',
'static/js/markdown.js',
'static/js/message_store.js',