stream_data: Add get_invite_stream_data helper function.

This function unlike `invite_streams()` returns an array of objects having
various info (name, stream_id, invite_only, default_stream) related to
streams rather than an array of names of streams.
This commit is contained in:
Shubham Dhama
2019-01-10 22:27:35 +05:30
committed by Tim Abbott
parent a7fb7d1f5c
commit fbd73ba637
2 changed files with 65 additions and 0 deletions

View File

@@ -745,3 +745,44 @@ run_test('edge_cases', () => {
// just make sure we don't explode
stream_data.sort_for_stream_settings(bad_stream_ids);
});
run_test('get_invite_stream_data', () => {
// add default stream
var orie = {
name: 'Orie',
stream_id: 320,
invite_only: false,
subscribed: true,
};
// clear all the data form stream_data, and people
stream_data.clear_subscriptions();
people.init();
stream_data.add_sub('Orie', orie);
stream_data.set_realm_default_streams([orie]);
var expected_list = [{
name: 'Orie',
stream_id: 320,
invite_only: false,
default_stream: true,
}];
assert.deepEqual(stream_data.get_invite_stream_data(), expected_list);
var inviter = {
name: 'Inviter',
stream_id: 25,
invite_only: true,
subscribed: true,
};
stream_data.add_sub('Inviter', inviter);
expected_list.push({
name: 'Inviter',
stream_id: 25,
invite_only: true,
default_stream: false,
});
assert.deepEqual(stream_data.get_invite_stream_data(), expected_list);
});