Skip to content

Commit

Permalink
Backport #5090 and #4694
Browse files Browse the repository at this point in the history
  • Loading branch information
jbudz committed Oct 9, 2015
1 parent efe3456 commit 0dd60ed
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/kibana/components/stringify/types/Date.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ define(function (require) {
if (this._memoizedPattern !== pattern) {
this._memoizedPattern = pattern;
this._memoizedConverter = _.memoize(function converter(val) {
if (val === null || val === undefined) {
return '-';
}
return moment(val).format(pattern);
});
}
Expand Down
20 changes: 20 additions & 0 deletions test/unit/specs/components/stringify/_date.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
define(function (require) {
return ['Date format', function () {
var fieldFormats;

beforeEach(module('kibana'));
beforeEach(inject(function (Private) {
fieldFormats = Private(require('registry/field_formats'));
}));

it('decoding an undefined or null date should return an empty string', function () {
var DateFormat = fieldFormats.getType('date');
var date = new DateFormat({
pattern: 'dd-MM-yyyy'
});
expect(date.convert(null)).to.be('-');
expect(date.convert(undefined)).to.be('-');
});

}];
});
1 change: 1 addition & 0 deletions test/unit/specs/components/stringify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ define(function (require) {
describe(require('specs/components/stringify/_ip'));
describe(require('specs/components/stringify/_source'));
describe(require('specs/components/stringify/_url'));
describe(require('specs/components/stringify/_date'));
});
});

0 comments on commit 0dd60ed

Please sign in to comment.