Skip to content

Commit d79d00a

Browse files
Fix lib_date_test (missing extraFormats parameter passed to formatDate)
1 parent e6250a0 commit d79d00a

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

test/jasmine/tests/lib_date_test.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,12 @@ describe('dates', function() {
482482
describe('formatDate', function() {
483483
function assertFormatRounds(ms, calendar, results) {
484484
['y', 'm', 'd', 'M', 'S', 1, 2, 3, 4].forEach(function(tr, i) {
485-
expect(Lib.formatDate(ms, '', tr, utcFormat, calendar))
485+
expect(Lib.formatDate(ms, '', tr, utcFormat, calendar, {
486+
year: '%Y',
487+
month: '%b %Y',
488+
dayMonth: '%b %-d',
489+
dayMonthYear: '%b %-d, %Y'
490+
}))
486491
.toBe(results[i], calendar);
487492
});
488493
}
@@ -598,17 +603,23 @@ describe('dates', function() {
598603
});
599604

600605
it('should remove extra fractional second zeros', function() {
601-
expect(Lib.formatDate(0.1, '', 4, utcFormat)).toBe('00:00:00.0001\nJan 1, 1970');
602-
expect(Lib.formatDate(0.1, '', 3, utcFormat)).toBe('00:00:00\nJan 1, 1970');
603-
expect(Lib.formatDate(0.1, '', 0, utcFormat)).toBe('00:00:00\nJan 1, 1970');
604-
expect(Lib.formatDate(0.1, '', 'S', utcFormat)).toBe('00:00:00\nJan 1, 1970');
605-
expect(Lib.formatDate(0.1, '', 3, utcFormat, 'coptic'))
606+
var extraFormat = {
607+
year: '%Y',
608+
month: '%b %Y',
609+
dayMonth: '%b %-d',
610+
dayMonthYear: '%b %-d, %Y'
611+
};
612+
expect(Lib.formatDate(0.1, '', 4, utcFormat, null, extraFormat)).toBe('00:00:00.0001\nJan 1, 1970');
613+
expect(Lib.formatDate(0.1, '', 3, utcFormat, null, extraFormat)).toBe('00:00:00\nJan 1, 1970');
614+
expect(Lib.formatDate(0.1, '', 0, utcFormat, null, extraFormat)).toBe('00:00:00\nJan 1, 1970');
615+
expect(Lib.formatDate(0.1, '', 'S', utcFormat, null, extraFormat)).toBe('00:00:00\nJan 1, 1970');
616+
expect(Lib.formatDate(0.1, '', 3, utcFormat, 'coptic', extraFormat))
606617
.toBe('00:00:00\nKoi 23, 1686');
607618

608619
// because the decimal point is explicitly part of the format
609620
// string here, we can't remove it OR the very first zero after it.
610-
expect(Lib.formatDate(0.1, '%S.%f', null, utcFormat)).toBe('00.0001');
611-
expect(Lib.formatDate(0.1, '%S.%3f', null, utcFormat)).toBe('00.0');
621+
expect(Lib.formatDate(0.1, '%S.%f', null, utcFormat, null, extraFormat)).toBe('00.0001');
622+
expect(Lib.formatDate(0.1, '%S.%3f', null, utcFormat, null, extraFormat)).toBe('00.0');
612623
});
613624

614625
});

0 commit comments

Comments
 (0)