Repository: ambari Updated Branches: refs/heads/branch-2.1 3b573c290 -> c764f1cca
AMBARI-13497. Ambari Web: Timezone issues (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c764f1cc Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c764f1cc Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c764f1cc Branch: refs/heads/branch-2.1 Commit: c764f1ccaafc9a76e453b26b10ba56e53417bbd5 Parents: 3b573c2 Author: Oleg Nechiporenko <onechipore...@apache.org> Authored: Wed Oct 21 11:43:21 2015 +0300 Committer: Oleg Nechiporenko <onechipore...@apache.org> Committed: Wed Oct 21 11:43:21 2015 +0300 ---------------------------------------------------------------------- .../global/background_operations_controller.js | 18 ++--- .../global/user_settings_controller.js | 74 ++++++++++++++------ ambari-web/app/messages.js | 1 + ambari-web/app/styles/application.less | 8 +++ .../app/templates/common/chart/linear_time.hbs | 5 +- ambari-web/app/templates/common/settings.hbs | 2 +- ambari-web/app/utils/date/timezone.js | 39 ++++++----- ambari-web/app/utils/helper.js | 2 +- .../global/user_settings_controller_test.js | 30 +++++++- ambari-web/test/utils/date/timezone_test.js | 36 +++++----- 10 files changed, 144 insertions(+), 71 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/c764f1cc/ambari-web/app/controllers/global/background_operations_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/global/background_operations_controller.js b/ambari-web/app/controllers/global/background_operations_controller.js index 2cc3057..b78a35b 100644 --- a/ambari-web/app/controllers/global/background_operations_controller.js +++ b/ambari-web/app/controllers/global/background_operations_controller.js @@ -222,11 +222,13 @@ App.BackgroundOperationsController = Em.Controller.extend({ currentRequestIds.push(request.Requests.id); if (rq) { - rq.set('progress', Math.floor(request.Requests.progress_percent)); - rq.set('status', request.Requests.request_status); - rq.set('isRunning', isRunning); - rq.set('startTime', request.Requests.start_time); - rq.set('endTime', request.Requests.end_time); + rq.setProperties({ + progress: Math.floor(request.Requests.progress_percent), + status: request.Requests.request_status, + isRunning: isRunning, + startTime: App.dateTimeWithTimeZone(request.Requests.start_time), + endTime: App.dateTimeWithTimeZone(request.Requests.end_time) + }); } else { rq = Em.Object.create({ id: request.Requests.id, @@ -246,7 +248,7 @@ App.BackgroundOperationsController = Em.Controller.extend({ }); this.get("services").unshift(rq); //To sort DESC by request id - this.set("services", this.get("services").sort( function(a,b) { return b.get('id') - a.get('id'); })); + this.set("services", this.get("services").sortProperty('id').reverse()); } runningServices += ~~isRunning; }, this); @@ -294,7 +296,7 @@ App.BackgroundOperationsController = Em.Controller.extend({ return false }, /** - * assign schedule_id of request to null if it's Recommision operation + * assign schedule_id of request to null if it's Recommission operation * @param request * @param requestParams */ @@ -361,7 +363,7 @@ App.BackgroundOperationsController = Em.Controller.extend({ $(self.get('popupView.element')).appendTo('#wrapper'); } else { self.set('popupView', App.HostPopup.initPopup("", self, true)); - self.set ('popupView.isNotShowBgChecked', !initValue); + self.set('popupView.isNotShowBgChecked', !initValue); } }); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/c764f1cc/ambari-web/app/controllers/global/user_settings_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/global/user_settings_controller.js b/ambari-web/app/controllers/global/user_settings_controller.js index 4ad7786..e78ada0 100644 --- a/ambari-web/app/controllers/global/user_settings_controller.js +++ b/ambari-web/app/controllers/global/user_settings_controller.js @@ -36,7 +36,8 @@ App.UserSettingsController = Em.Controller.extend(App.UserPref, { userSettings: {}, /** - * Each property type is {name: string, defaultValue: *} + * Each property's type is {name: string, defaultValue: *, formatter: function} + * * @type {object} */ userSettingsKeys: function () { @@ -49,7 +50,10 @@ App.UserSettingsController = Em.Controller.extend(App.UserPref, { }, timezone: { name: prefix + 'timezone-' + loginName, - defaultValue: timezoneUtils.detectUserTimezone() + defaultValue: timezoneUtils.detectUserTimezone(), + formatter: function (v) { + return timezoneUtils.get('timezonesMappedByValue')[v]; + } } }; }.property('App.router.loginName'), @@ -57,6 +61,7 @@ App.UserSettingsController = Em.Controller.extend(App.UserPref, { /** * Load some user's setting from the persist * If <code>persistKey</code> is not provided, all settings are loaded + * * @param {string} [persistKey] * @method dataLoading * @returns {$.Deferred.promise} @@ -73,14 +78,30 @@ App.UserSettingsController = Em.Controller.extend(App.UserPref, { return dfd.promise(); }, - getUserPrefSuccessCallback: function (response) { - if (!Em.isNone(response)) { - this.updateUserPrefWithDefaultValues(response); + /** + * Success-callback for user pref + * + * @param {*} response + * @param {object} opt + * @returns {*} + * @method getUserPrefSuccessCallback + */ + getUserPrefSuccessCallback: function (response, opt) { + var getAllRequest = opt.url.contains('persist/?_'); + if (Em.isNone(response)) { + this.updateUserPrefWithDefaultValues(response, getAllRequest); } this.set('currentPrefObject', response); return response; }, + /** + * Error-callback for user-pref request + * Update user pref with default values if user firstly login + * + * @param {object} request + * @method getUserPrefErrorCallback + */ getUserPrefErrorCallback: function (request) { // this user is first time login if (404 == request.status) { @@ -90,14 +111,26 @@ App.UserSettingsController = Em.Controller.extend(App.UserPref, { /** * Load all current user's settings to the <code>userSettings</code> + * * @method getAllUserSettings */ getAllUserSettings: function () { var userSettingsKeys = this.get('userSettingsKeys'); var userSettings = {}; + var self = this; this.dataLoading().done(function (json) { Object.keys(userSettingsKeys).forEach(function (k) { - userSettings[k] = JSON.parse(json[userSettingsKeys[k].name]); + var value = userSettingsKeys[k].defaultValue; + if (undefined === json[userSettingsKeys[k].name]) { + self.postUserPref(k, userSettingsKeys[k].defaultValue); + } + else { + value = JSON.parse(json[userSettingsKeys[k].name]); + } + if ('function' === Em.typeOf(userSettingsKeys[k].formatter)) { + value = userSettingsKeys[k].formatter(value); + } + userSettings[k] = value; }); }); this.set('userSettings', userSettings); @@ -106,18 +139,22 @@ App.UserSettingsController = Em.Controller.extend(App.UserPref, { /** * If user doesn't have any settings stored in the persist, * default values should be populated there + * * @param {object} [response] + * @param {boolean} [getAllRequest] determines, if user tried to get one field or all fields * @method updateUserPrefWithDefaultValues */ - updateUserPrefWithDefaultValues: function (response) { + updateUserPrefWithDefaultValues: function (response, getAllRequest) { response = response || {}; var keys = this.get('userSettingsKeys'); var self = this; - Object.keys(keys).forEach(function (key) { - if (Em.isNone(response[keys[key].name])) { - self.postUserPref(key, keys[key].defaultValue); - } - }); + if (getAllRequest) { + Object.keys(keys).forEach(function (key) { + if (Em.isNone(response[keys[key].name])) { + self.postUserPref(key, keys[key].defaultValue); + } + }); + } }, /** @@ -125,6 +162,7 @@ App.UserSettingsController = Em.Controller.extend(App.UserPref, { * Example: * real key is something like 'userSettingsKeys.timezone.name' * but user should call this method with 'timezone' + * * @method postUserPref * @param {string} key * @param {*} value @@ -132,19 +170,12 @@ App.UserSettingsController = Em.Controller.extend(App.UserPref, { */ postUserPref: function (key, value) { var k = key.startsWith('userSettingsKeys.') ? key : 'userSettingsKeys.' + key + '.name'; + var kk = k.replace('userSettingsKeys.', '').replace('.name', ''); + this.set('userSettings.' + kk, value); return this._super(this.get(k), value); }, /** - * Sync <code>userSettingsKeys</code> after each POST-update - * @returns {*} - */ - postUserPrefSuccessCallback: function () { - return this.getAllUserSettings(); - }, - - /** - * Check if popup may be opened (based on <code>upgrade_ADMIN</code>) * Open popup with user settings after settings-request is complete * * @method showSettingsPopup @@ -214,6 +245,7 @@ App.UserSettingsController = Em.Controller.extend(App.UserPref, { /** * Determines if page should be refreshed after user click "Save" + * * @returns {boolean} */ needsPageRefresh: function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/c764f1cc/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index be97fc8..32110dd 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -279,6 +279,7 @@ Em.I18n.translations = { 'common.csv': 'CSV', 'common.json': 'JSON', 'common.timestamp': 'Timestamp', + 'common.timezone': 'Timezone', 'common.loading.eclipses': 'Loading...', 'models.alert_instance.tiggered.verbose': "Occurred on {0} <br> Checked on {1}", http://git-wip-us.apache.org/repos/asf/ambari/blob/c764f1cc/ambari-web/app/styles/application.less ---------------------------------------------------------------------- diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less index 6489677..a7a2578 100644 --- a/ambari-web/app/styles/application.less +++ b/ambari-web/app/styles/application.less @@ -5555,6 +5555,14 @@ input[type="radio"].align-checkbox, input[type="checkbox"].align-checkbox { margin-top: @space-m; } +.mtl { + margin-top: @space-l; +} + +.mtl15 { + margin-top: @space-l * 1.5; +} + .mbm { margin-bottom: @space-m; } .mls { http://git-wip-us.apache.org/repos/asf/ambari/blob/c764f1cc/ambari-web/app/templates/common/chart/linear_time.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/chart/linear_time.hbs b/ambari-web/app/templates/common/chart/linear_time.hbs index e7bfa97..60937de 100644 --- a/ambari-web/app/templates/common/chart/linear_time.hbs +++ b/ambari-web/app/templates/common/chart/linear_time.hbs @@ -20,7 +20,7 @@ <div {{bindAttr class="view.isReady::hidden :time-label"}}> {{view.parentView.currentTimeState.name}} <a {{bindAttr class="view.isExportButtonHidden:hidden :corner-icon :pull-right"}} href="#" {{action toggleFormatsList target="view"}}> - <i class="icon-save"></i> + {{t common.export}} <i class="icon-save"></i> </a> {{view view.exportMetricsMenuView}} </div> @@ -37,3 +37,6 @@ {{#if view.isTimePagingEnable}} <div {{bindAttr class="view.rightArrowVisible:visibleArrow :arrow-right"}} {{action "switchTimeForward" "forward" target="view.parentView"}}></div> {{/if}} +<div class="timezone mtl15 mll"> + {{t common.timezone}}: <strong>{{App.router.userSettingsController.userSettings.timezone.label}}</strong> +</div> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/c764f1cc/ambari-web/app/templates/common/settings.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/settings.hbs b/ambari-web/app/templates/common/settings.hbs index 4ffc888..2254c17 100644 --- a/ambari-web/app/templates/common/settings.hbs +++ b/ambari-web/app/templates/common/settings.hbs @@ -32,7 +32,7 @@ {{t app.settings.selectTimezone}} {{view Em.Select contentBinding="view.timezonesList" - optionLabelPath="content.value" + optionLabelPath="content.label" optionValuePath="content.value" selectionBinding="view.parentView.selectedTimezone" class="group-select select-group-box" http://git-wip-us.apache.org/repos/asf/ambari/blob/c764f1cc/ambari-web/app/utils/date/timezone.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/date/timezone.js b/ambari-web/app/utils/date/timezone.js index 2d8a550..2421fca 100644 --- a/ambari-web/app/utils/date/timezone.js +++ b/ambari-web/app/utils/date/timezone.js @@ -34,10 +34,11 @@ var dataUtils = require('utils/data_manipulation'); * List of timezones used in the user's settings popup * * <code>utcOffset</code> - offset-value (0, 180, 240 etc) - * <code>value</code> - string like '(UTC+02:00) Europe / Athens, Kiev, Minsk' + * <code>value</code> - string like '120180|Europe' + * <code>label</code> - string like '(UTC+02:00) Europe / Athens, Kiev, Minsk' * <code>zones</code> - list of zone-objects from <code>moment.tz</code> included to the <code>value</code> * - * @typedef {{utcOffset: number, label: string, value: string, zones: object[]}} shownTimezone + * @typedef {{utcOffset: number, label: string, value: string, label: string, zones: object[]}} shownTimezone */ module.exports = Em.Object.create({ @@ -56,7 +57,7 @@ module.exports = Em.Object.create({ * @type {object} * @readOnly */ - timezonesMappedByLabel: function () { + timezonesMappedByValue: function () { var ret = {}; this.get('timezones').forEach(function (tz) { ret[tz.value] = tz; @@ -176,24 +177,24 @@ module.exports = Em.Object.create({ * Example: * <pre> * var zones = [ - * {groupByKey: 1, formattedOffset: '+01:00', value: 'a/Aa', region: 'a', city: 'Aa'}, - * {groupByKey: 1, formattedOffset: '+01:00', value: 'a/Bb', region: 'a', city: 'Bb'}, - * {groupByKey: 2, formattedOffset: '+02:00', value: 'a/Cc', region: 'a', city: 'Cc'}, - * {groupByKey: 2, formattedOffset: '+02:00', value: 'a/Dd', region: 'a', city: 'Dd'}, - * {groupByKey: 1, formattedOffset: '+01:00', value: 'b/Ee', region: 'b', city: 'Ee'}, - * {groupByKey: 1, formattedOffset: '+01:00', value: 'b/Ff', region: 'b', city: 'Ff'}, - * {groupByKey: 2, formattedOffset: '+02:00', value: 'b/Gg', region: 'b', city: 'Gg'}, - * {groupByKey: 2, formattedOffset: '+02:00', value: 'b/Hh', region: 'b', city: 'Hh'}, - * {groupByKey: 2, formattedOffset: '+02:00', value: 'b/II', region: 'b', city: 'II'}, // will be ignored, because city is abbreviation - * {groupByKey: 2, formattedOffset: '+02:00', value: 'b', region: 'b', city: '' } // will be ignored, because city is empty + * {groupByKey: '1', formattedOffset: '+01:00', value: 'a/Aa', region: 'a', city: 'Aa'}, + * {groupByKey: '1', formattedOffset: '+01:00', value: 'a/Bb', region: 'a', city: 'Bb'}, + * {groupByKey: '2', formattedOffset: '+02:00', value: 'a/Cc', region: 'a', city: 'Cc'}, + * {groupByKey: '2', formattedOffset: '+02:00', value: 'a/Dd', region: 'a', city: 'Dd'}, + * {groupByKey: '1', formattedOffset: '+01:00', value: 'b/Ee', region: 'b', city: 'Ee'}, + * {groupByKey: '1', formattedOffset: '+01:00', value: 'b/Ff', region: 'b', city: 'Ff'}, + * {groupByKey: '2', formattedOffset: '+02:00', value: 'b/Gg', region: 'b', city: 'Gg'}, + * {groupByKey: '2', formattedOffset: '+02:00', value: 'b/Hh', region: 'b', city: 'Hh'}, + * {groupByKey: '2', formattedOffset: '+02:00', value: 'b/II', region: 'b', city: 'II'}, // will be ignored, because city is abbreviation + * {groupByKey: '2', formattedOffset: '+02:00', value: 'b', region: 'b', city: '' } // will be ignored, because city is empty * ]; * var groupedZones = _groupTimezones(zones); * // groupedZones is: * [ - * {utcOffset: 1, value: '(UTC+01:00) a / Aa, Bb'}, - * {utcOffset: 1, value: '(UTC+01:00) b / Ee, Ff'}, - * {utcOffset: 2, value: '(UTC+02:00) a / Cc, Dd'}, - * {utcOffset: 2, value: '(UTC+02:00) b / Gg, Hh'} + * {utcOffset: 1, label: '(UTC+01:00) a / Aa, Bb', value: '1|a'}, + * {utcOffset: 1, label: '(UTC+01:00) b / Ee, Ff', value: '1|b'}, + * {utcOffset: 2, label: '(UTC+02:00) a / Cc, Dd', value: '2|a'}, + * {utcOffset: 2, label: '(UTC+02:00) b / Gg, Hh', value: '2|b'} * ] * </pre> * @@ -213,9 +214,11 @@ module.exports = Em.Object.create({ }).uniq().join(', '); var formattedOffset = Em.get(groupedByRegionZones[region], 'firstObject.formattedOffset'); var utcOffset = Em.get(groupedByRegionZones[region], 'firstObject.utcOffset'); + var value = Em.get(groupedByRegionZones[region], 'firstObject.groupByKey') + '|' + region; newZones.pushObject({ utcOffset: utcOffset, - value: '(UTC' + formattedOffset + ') ' + region + (cities ? ' / ' + cities : ''), + label: '(UTC' + formattedOffset + ') ' + region + (cities ? ' / ' + cities : ''), + value: value, zones: groupedByRegionZones[region] }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/c764f1cc/ambari-web/app/utils/helper.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/helper.js b/ambari-web/app/utils/helper.js index 46834c5..ee43ea1 100644 --- a/ambari-web/app/utils/helper.js +++ b/ambari-web/app/utils/helper.js @@ -629,7 +629,7 @@ App.dateTime = function() { App.dateTimeWithTimeZone = function (x) { var timezone = App.router.get('userSettingsController.userSettings.timezone'); if (timezone) { - var tz = Em.getWithDefault(timezoneUtils.get('timezonesMappedByLabel')[timezone], 'zones.0.value', ''); + var tz = Em.getWithDefault(timezone, 'zones.0.value', ''); return moment(moment.tz(x ? new Date(x) : new Date(), tz).toArray()).toDate().getTime(); } return x || new Date().getTime(); http://git-wip-us.apache.org/repos/asf/ambari/blob/c764f1cc/ambari-web/test/controllers/global/user_settings_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/global/user_settings_controller_test.js b/ambari-web/test/controllers/global/user_settings_controller_test.js index 99a7df2..92bb346 100644 --- a/ambari-web/test/controllers/global/user_settings_controller_test.js +++ b/ambari-web/test/controllers/global/user_settings_controller_test.js @@ -24,7 +24,13 @@ describe('App.UserSettingsController', function () { beforeEach(function () { userSettingsController = App.UserSettingsController.create(); }); - + + describe('#userSettingsKeys', function () { + it('should not be empty', function () { + expect(Object.keys(userSettingsController.get('userSettingsKeys'))).to.have.length.gt(0); + }); + }); + describe('#showSettingsPopup', function() { var dataToShowRes = {}; @@ -71,4 +77,26 @@ describe('App.UserSettingsController', function () { }); }); + describe('#updateUserPrefWithDefaultValues', function () { + + beforeEach(function () { + sinon.stub(userSettingsController, 'postUserPref', Em.K); + }); + + afterEach(function () { + userSettingsController.postUserPref.restore(); + }); + + it('should update user pref with default values', function () { + userSettingsController.updateUserPrefWithDefaultValues(null, true); + expect(userSettingsController.postUserPref.called).to.be.false; + }); + + it('should not update user pref with default values', function () { + userSettingsController.updateUserPrefWithDefaultValues(null, false); + expect(userSettingsController.postUserPref.called).to.be.true; + }); + + }); + }); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/c764f1cc/ambari-web/test/utils/date/timezone_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/date/timezone_test.js b/ambari-web/test/utils/date/timezone_test.js index 4b9027a..837557b 100644 --- a/ambari-web/test/utils/date/timezone_test.js +++ b/ambari-web/test/utils/date/timezone_test.js @@ -23,16 +23,16 @@ describe('timezoneUtils', function () { describe('#_groupTimezones', function () { var formattedTimezones = [ - {utcOffset: 1, groupByKey: 1, formattedOffset: '+01:00', value: 'a/Aa', region: 'a', city: 'Aa'}, - {utcOffset: 1, groupByKey: 1, formattedOffset: '+01:00', value: 'a/Bb', region: 'a', city: 'Bb'}, - {utcOffset: 2, groupByKey: 2, formattedOffset: '+02:00', value: 'a/Cc', region: 'a', city: 'Cc'}, - {utcOffset: 2, groupByKey: 2, formattedOffset: '+02:00', value: 'a/Dd', region: 'a', city: 'Dd'}, - {utcOffset: 1, groupByKey: 1, formattedOffset: '+01:00', value: 'b/Ee', region: 'b', city: 'Ee'}, - {utcOffset: 1, groupByKey: 1, formattedOffset: '+01:00', value: 'b/Ff', region: 'b', city: 'Ff'}, - {utcOffset: 2, groupByKey: 2, formattedOffset: '+02:00', value: 'b/Gg', region: 'b', city: 'Gg'}, - {utcOffset: 2, groupByKey: 2, formattedOffset: '+02:00', value: 'b/Hh', region: 'b', city: 'Hh'}, - {utcOffset: 2, groupByKey: 2, formattedOffset: '+02:00', value: 'b/II', region: 'b', city: 'II'}, - {utcOffset: 2, groupByKey: 2, formattedOffset: '+02:00', value: 'b', region: 'b', city: ''} + {utcOffset: 1, groupByKey: '1', formattedOffset: '+01:00', value: 'a/Aa', region: 'a', city: 'Aa'}, + {utcOffset: 1, groupByKey: '1', formattedOffset: '+01:00', value: 'a/Bb', region: 'a', city: 'Bb'}, + {utcOffset: 2, groupByKey: '2', formattedOffset: '+02:00', value: 'a/Cc', region: 'a', city: 'Cc'}, + {utcOffset: 2, groupByKey: '2', formattedOffset: '+02:00', value: 'a/Dd', region: 'a', city: 'Dd'}, + {utcOffset: 1, groupByKey: '1', formattedOffset: '+01:00', value: 'b/Ee', region: 'b', city: 'Ee'}, + {utcOffset: 1, groupByKey: '1', formattedOffset: '+01:00', value: 'b/Ff', region: 'b', city: 'Ff'}, + {utcOffset: 2, groupByKey: '2', formattedOffset: '+02:00', value: 'b/Gg', region: 'b', city: 'Gg'}, + {utcOffset: 2, groupByKey: '2', formattedOffset: '+02:00', value: 'b/Hh', region: 'b', city: 'Hh'}, + {utcOffset: 2, groupByKey: '2', formattedOffset: '+02:00', value: 'b/II', region: 'b', city: 'II'}, + {utcOffset: 2, groupByKey: '2', formattedOffset: '+02:00', value: 'b', region: 'b', city: ''} ]; before(function () { @@ -52,7 +52,7 @@ describe('timezoneUtils', function () { '(UTC+01:00) b / Ee, Ff', '(UTC+02:00) a / Cc, Dd', '(UTC+02:00) b / Gg, Hh']; - var values = this.result.mapProperty('value'); + var values = this.result.mapProperty('label'); expect(values).to.eql(expected); expect(values.join('')).to.not.contain('II'); expect(values.join('')).to.not.contain(', ,'); @@ -139,35 +139,31 @@ describe('timezoneUtils', function () { it('Detect UTC+1', function () { mockTimezoneOffset(0, 60); var tz = timezoneUtils.detectUserTimezone(); - expect(tz).to.contain('(UTC+01:00) Atlantic'); + expect(tz).to.contain('0-60|Atlantic'); }); it('Detect UTC+1 for Europe', function () { mockTimezoneOffset(0, 60); var tz = timezoneUtils.detectUserTimezone('Europe'); - expect(tz).to.contain('(UTC+01:00) Europe'); - expect(tz).to.contain('London'); + expect(tz).to.contain('0-60|Europe'); }); it('Detect UTC-4', function () { mockTimezoneOffset(-300, -240); var tz = timezoneUtils.detectUserTimezone(); - expect(tz).to.contain('(UTC-04:00) America'); - expect(tz).to.contain('New York'); + expect(tz).to.contain('300240|America'); }); it('Detect UTC+3 for Asia', function () { mockTimezoneOffset(120, 180); var tz = timezoneUtils.detectUserTimezone(); - expect(tz).to.contain('(UTC+03:00) Asia'); - expect(tz).to.contain('Damascus'); + expect(tz).to.contain('-120-180|Asia'); }); it('Detect UTC-7', function () { mockTimezoneOffset(-480, -420); var tz = timezoneUtils.detectUserTimezone(); - expect(tz).to.contain('(UTC-07:00) America'); - expect(tz).to.contain('Los Angeles'); + expect(tz).to.contain('480420|America'); }); });