2020-02-25 12:46:14 +01:00
|
|
|
const settings_data = zrequire('settings_data');
|
2020-03-07 01:15:34 +01:00
|
|
|
const settings_config = zrequire('settings_config');
|
2020-02-25 12:46:14 +01:00
|
|
|
|
|
|
|
set_global('page_params', {});
|
|
|
|
|
|
|
|
/*
|
|
|
|
Some methods in settings_data are fairly
|
|
|
|
trivial, so the meaningful tests happen
|
|
|
|
at the higher layers, such as when we
|
|
|
|
test people.js.
|
|
|
|
*/
|
|
|
|
|
|
|
|
const isaac = {
|
|
|
|
email: 'isaac@example.com',
|
|
|
|
delivery_email: 'isaac-delivery@example.com',
|
|
|
|
};
|
|
|
|
|
|
|
|
run_test('email_for_user_settings', () => {
|
|
|
|
const email = settings_data.email_for_user_settings;
|
|
|
|
|
2020-03-07 01:15:34 +01:00
|
|
|
page_params.realm_email_address_visibility = settings_config.email_address_visibility_values
|
|
|
|
.admins_only.code;
|
2020-02-25 12:46:14 +01:00
|
|
|
assert.equal(email(isaac), undefined);
|
|
|
|
|
|
|
|
page_params.is_admin = true;
|
|
|
|
assert.equal(email(isaac), isaac.delivery_email);
|
|
|
|
|
2020-03-07 01:15:34 +01:00
|
|
|
page_params.realm_email_address_visibility = settings_config.email_address_visibility_values
|
|
|
|
.nobody.code;
|
|
|
|
assert.equal(email(isaac), undefined);
|
2020-02-25 12:46:14 +01:00
|
|
|
|
|
|
|
page_params.is_admin = false;
|
2020-03-07 01:15:34 +01:00
|
|
|
assert.equal(email(isaac), undefined);
|
|
|
|
|
|
|
|
page_params.realm_email_address_visibility = settings_config.email_address_visibility_values
|
|
|
|
.everyone.code;
|
2020-02-25 12:46:14 +01:00
|
|
|
assert.equal(email(isaac), isaac.email);
|
|
|
|
});
|