Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #18639 from crdlc/bug-1000454
Browse files Browse the repository at this point in the history
Bug 1000454 - [B2G][1.4][Gaia]: The timestamp for a file downloaded a we...
  • Loading branch information
Cristian Rodriguez committed Apr 28, 2014
2 parents 1094892 + 95f4fd3 commit d4d02d2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
29 changes: 29 additions & 0 deletions apps/settings/test/unit/download_formatter_test.js
Expand Up @@ -4,11 +4,18 @@
require('/shared/test/unit/mocks/mock_download.js');
requireApp('settings/test/unit/mock_l10n.js');
require('/shared/js/download/download_formatter.js');
require('/shared/test/unit/mocks/mock_lazy_loader.js');


suite('DownloadFormatter', function() {
var realL10n;

var mocksHelperForDownloadFormatter = new MocksHelper([
'LazyLoader'
]).init();

mocksHelperForDownloadFormatter.attachTestHelpers();

suiteSetup(function() {
realL10n = navigator.mozL10n;
navigator.mozL10n = MockL10n;
Expand Down Expand Up @@ -208,4 +215,26 @@ suite('DownloadFormatter', function() {
var retrievedUUID = DownloadFormatter.getUUID(mockDownload);
assert.equal(retrievedUUID, expectedUUID);
});

test(' getDate', function(done) {
var now = new Date();
var expectedPrettyDate = 'pretty' + now.toString();
var stub = sinon.stub(navigator.mozL10n, 'DateTimeFormat', function(date) {
return {
fromNow: function(date, useCompactFormat) {
assert.isUndefined(useCompactFormat);
return 'pretty' + date.toString();
}
};
});

var mockDownload = new MockDownload({
startTime: now
});

DownloadFormatter.getDate(mockDownload, function(date) {
assert.equal(date, expectedPrettyDate);
done();
});
});
});
2 changes: 1 addition & 1 deletion shared/js/download/download_formatter.js
Expand Up @@ -74,7 +74,7 @@
}

LazyLoader.load(['shared/js/l10n_date.js'], function onload() {
var prettyDate = navigator.mozL10n.DateTimeFormat().fromNow(date, true);
var prettyDate = navigator.mozL10n.DateTimeFormat().fromNow(date);
callback && callback(prettyDate);
});
},
Expand Down

0 comments on commit d4d02d2

Please sign in to comment.