2016-10-26 12:50:00 +02:00
|
|
|
(function (root, factory) {
|
2018-06-03 16:40:20 +02:00
|
|
|
define(["jasmine"], factory);
|
2019-10-09 16:01:38 +02:00
|
|
|
} (this, function () {
|
2016-12-20 10:30:20 +01:00
|
|
|
var utils = converse.env.utils,
|
|
|
|
_ = converse.env._;
|
2016-10-26 12:50:00 +02:00
|
|
|
|
|
|
|
return describe("Converse.js Utilities", function() {
|
|
|
|
|
|
|
|
it("applyUserSettings: recursively applies user settings", function () {
|
|
|
|
var context = {};
|
|
|
|
var settings = {
|
|
|
|
show_toolbar: true,
|
|
|
|
chatview_avatar_width: 32,
|
|
|
|
chatview_avatar_height: 32,
|
2016-11-22 09:55:52 +01:00
|
|
|
auto_join_rooms: [],
|
2016-10-26 12:50:00 +02:00
|
|
|
visible_toolbar_buttons: {
|
2017-07-15 11:55:07 +02:00
|
|
|
'emojis': true,
|
2016-10-26 12:50:00 +02:00
|
|
|
'call': false,
|
|
|
|
'clear': true,
|
|
|
|
'toggle_occupants': true
|
|
|
|
}
|
|
|
|
};
|
|
|
|
_.extend(context, settings);
|
|
|
|
|
|
|
|
var user_settings = {
|
|
|
|
something_else: 'xxx',
|
|
|
|
show_toolbar: false,
|
|
|
|
chatview_avatar_width: 32,
|
|
|
|
chatview_avatar_height: 48,
|
2016-11-22 09:55:52 +01:00
|
|
|
auto_join_rooms: [
|
|
|
|
'anonymous@conference.nomnom.im',
|
|
|
|
],
|
2016-10-26 12:50:00 +02:00
|
|
|
visible_toolbar_buttons: {
|
2017-07-15 11:55:07 +02:00
|
|
|
'emojis': false,
|
2016-10-26 12:50:00 +02:00
|
|
|
'call': false,
|
|
|
|
'toggle_occupants':false,
|
|
|
|
'invalid': false
|
|
|
|
}
|
|
|
|
};
|
|
|
|
utils.applyUserSettings(context, settings, user_settings);
|
|
|
|
|
|
|
|
expect(context.something_else).toBeUndefined();
|
|
|
|
expect(context.show_toolbar).toBeFalsy();
|
|
|
|
expect(context.chatview_avatar_width).toBe(32);
|
|
|
|
expect(context.chatview_avatar_height).toBe(48);
|
2017-01-26 15:49:02 +01:00
|
|
|
expect(_.keys(context.visible_toolbar_buttons)).toEqual(_.keys(settings.visible_toolbar_buttons));
|
2017-07-15 11:55:07 +02:00
|
|
|
expect(context.visible_toolbar_buttons.emojis).toBeFalsy();
|
2016-10-26 12:50:00 +02:00
|
|
|
expect(context.visible_toolbar_buttons.call).toBeFalsy();
|
|
|
|
expect(context.visible_toolbar_buttons.toggle_occupants).toBeFalsy();
|
|
|
|
expect(context.visible_toolbar_buttons.invalid).toBeFalsy();
|
2016-11-22 09:55:52 +01:00
|
|
|
expect(context.auto_join_rooms.length).toBe(1);
|
|
|
|
expect(context.auto_join_rooms[0]).toBe('anonymous@conference.nomnom.im');
|
2016-10-27 13:30:58 +02:00
|
|
|
|
|
|
|
user_settings = {
|
|
|
|
visible_toolbar_buttons: {
|
|
|
|
'toggle_occupants': true
|
|
|
|
}
|
|
|
|
};
|
|
|
|
utils.applyUserSettings(context, settings, user_settings);
|
2017-01-26 15:49:02 +01:00
|
|
|
expect(_.keys(context.visible_toolbar_buttons)).toEqual(_.keys(settings.visible_toolbar_buttons));
|
2016-10-27 13:30:58 +02:00
|
|
|
expect(context.visible_toolbar_buttons.toggle_occupants).toBeTruthy();
|
2016-10-26 12:50:00 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}));
|