2017-02-24 16:18:56 +01:00
|
|
|
set_global('$', function () {
|
|
|
|
});
|
|
|
|
|
|
|
|
set_global('page_params', {
|
|
|
|
use_websockets: false,
|
|
|
|
});
|
|
|
|
|
|
|
|
set_global('document', {
|
|
|
|
location: {
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
add_dependencies({
|
2017-02-24 23:51:23 +01:00
|
|
|
people: 'js/people',
|
2017-02-24 16:18:56 +01:00
|
|
|
stream_data: 'js/stream_data',
|
|
|
|
util: 'js/util',
|
|
|
|
});
|
|
|
|
|
|
|
|
var compose = require('js/compose.js');
|
|
|
|
|
2017-03-18 18:48:43 +01:00
|
|
|
set_global('compose_state', {
|
|
|
|
recipient: compose.recipient,
|
|
|
|
});
|
|
|
|
|
2017-02-24 23:51:23 +01:00
|
|
|
var me = {
|
|
|
|
email: 'me@example.com',
|
|
|
|
user_id: 30,
|
|
|
|
full_name: 'Me Myself',
|
|
|
|
};
|
|
|
|
|
|
|
|
var alice = {
|
|
|
|
email: 'alice@example.com',
|
|
|
|
user_id: 31,
|
|
|
|
full_name: 'Alice',
|
|
|
|
};
|
|
|
|
|
|
|
|
var bob = {
|
|
|
|
email: 'bob@example.com',
|
|
|
|
user_id: 32,
|
|
|
|
full_name: 'Bob',
|
|
|
|
};
|
|
|
|
|
|
|
|
people.add(me);
|
|
|
|
people.initialize_current_user(me.user_id);
|
|
|
|
|
|
|
|
people.add(alice);
|
|
|
|
people.add(bob);
|
|
|
|
|
|
|
|
|
2017-02-24 16:18:56 +01:00
|
|
|
(function test_set_focused_recipient() {
|
|
|
|
var sub = {
|
|
|
|
stream_id: 101,
|
|
|
|
name: 'social',
|
|
|
|
subscribed: true,
|
|
|
|
};
|
|
|
|
stream_data.add_sub('social', sub);
|
|
|
|
|
|
|
|
var page = {
|
|
|
|
'#stream': 'social',
|
|
|
|
'#subject': 'lunch',
|
|
|
|
'#new_message_content': 'burrito',
|
|
|
|
'#private_message_recipient': 'alice@example.com, bob@example.com',
|
|
|
|
};
|
|
|
|
|
|
|
|
global.$ = function (selector) {
|
|
|
|
return {
|
|
|
|
val: function () {
|
|
|
|
return page[selector];
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-03-18 18:48:43 +01:00
|
|
|
global.compose_state.composing = function () {
|
2017-02-24 16:18:56 +01:00
|
|
|
return 'stream';
|
|
|
|
};
|
|
|
|
|
|
|
|
global.$.trim = function (s) {
|
|
|
|
return s;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-03-29 08:54:26 +02:00
|
|
|
var message = compose.create_message_object();
|
2017-02-24 16:18:56 +01:00
|
|
|
assert.equal(message.to, 'social');
|
|
|
|
assert.equal(message.subject, 'lunch');
|
|
|
|
assert.equal(message.content, 'burrito');
|
|
|
|
|
2017-03-18 18:48:43 +01:00
|
|
|
global.compose_state.composing = function () {
|
2017-02-24 16:18:56 +01:00
|
|
|
return 'private';
|
|
|
|
};
|
2017-03-29 08:54:26 +02:00
|
|
|
message = compose.create_message_object();
|
2017-02-24 16:18:56 +01:00
|
|
|
assert.deepEqual(message.to, ['alice@example.com', 'bob@example.com']);
|
2017-02-24 23:51:23 +01:00
|
|
|
assert.equal(message.to_user_ids, '31,32');
|
2017-02-24 16:18:56 +01:00
|
|
|
assert.equal(message.content, 'burrito');
|
|
|
|
|
|
|
|
}());
|