keeweb/test/src/util/formatting/date-format.js

19 lines
542 B
JavaScript
Raw Normal View History

2020-03-21 11:56:26 +01:00
import { expect } from 'chai';
2020-11-26 21:19:36 +01:00
import { DateFormat } from 'comp/util/date-format';
2020-03-21 11:56:26 +01:00
describe('DateFormat', () => {
2020-11-26 23:33:37 +01:00
const dt = new Date(2020, 0, 2, 3, 4, 5, 6);
2020-03-21 11:56:26 +01:00
it('should format date', () => {
expect(DateFormat.dStr(dt)).to.eql('Jan 2, 2020');
2020-03-21 11:56:26 +01:00
});
it('should format date and time', () => {
2020-11-26 23:33:37 +01:00
expect(DateFormat.dtStr(dt)).to.eql('Jan 2, 2020, 03:04:05');
2020-03-21 11:56:26 +01:00
});
it('should format date and time in sortable format', () => {
expect(DateFormat.dtStrFs(dt)).to.eql('2020-01-02T03-04-05');
});
});