diff --git a/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter.js b/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter.js index c642936add..8e9653ce8c 100644 --- a/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter.js +++ b/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter.js @@ -37,11 +37,12 @@ }, _timeFormat: String, + _timeFormatPromise: Object, // Used for testing. }, attached: function() { - this._getTimeFormat().then(function(timeFormat) { - this._timeFormat = timeFormat; + this._timeFormatPromise = this._getTimeFormat().then(function(tf) { + this._timeFormat = tf; }.bind(this)); }, diff --git a/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_test.html b/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_test.html index 341c7babfb..bdfd22b84d 100644 --- a/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_test.html +++ b/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_test.html @@ -129,14 +129,15 @@ limitations under the License. } suite('logged in', function() { - setup(function() { + setup(function(done) { return stubRestAPI(true, {time_format: 'HHMM_12'}).then(function() { element = fixture('basic'); + done(); }); }); test('Preferences are respected', function(done) { - flush(function() { + element._timeFormatPromise.then(function() { assert.equal(element._timeFormat, 'HHMM_12'); done(); }); @@ -144,14 +145,15 @@ limitations under the License. }); suite('logged out', function() { - setup(function() { + setup(function(done) { return stubRestAPI(false, null).then(function() { element = fixture('basic'); + done(); }); }); test('Default preferences are respected', function(done) { - flush(function() { + element._timeFormatPromise.then(function() { assert.equal(element._timeFormat, 'HHMM_24'); done(); });