fix(localize): empty dates should be formatted as empty string

This commit is contained in:
Thijs Louisse 2019-05-15 16:59:34 +02:00 committed by Thomas Allmer
parent 5255b1b77c
commit 6cfa301d1c
2 changed files with 3 additions and 3 deletions

View file

@ -10,7 +10,7 @@ import { normalizeDate } from './normalizeDate.js';
*/
export function formatDate(date, options) {
if (!(date instanceof Date)) {
return '0000-00-00';
return '';
}
const formatOptions = options || {};
// make sure months and days are always 2-digits

View file

@ -108,8 +108,8 @@ describe('formatDate', () => {
expect(formatDate(parsedDate, options)).to.equal('maandag 01 januari 1940');
});
it('returns a zero-date when input is not a Date object', async () => {
it('returns empty string when input is not a Date object', async () => {
const date = '1-1-2016';
expect(formatDate(date)).to.equal('0000-00-00');
expect(formatDate(date)).to.equal('');
});
});