const DateHelper = require('./date.helper');

const dateString = '2020-03-16T20:39:54.000';

describe('Date Helper', () => {
  describe('Format Date', () => {
    it('should format the date without time', () => {
      expect(DateHelper.formatDate(dateString)).toBe('Mar 16, 2020');
    });

    it('should format the date with the time', () => {
      const hour = new Date(dateString).getHours() - 12;
      expect(DateHelper.formatDate(dateString, DateHelper.DATETIME_FORMAT)).toBe(`Mar 16, 2020 ${hour}:39 PM`);
    });
  });

  describe('Validate Date', () => {
    it('should validate the date', () => {
      expect(DateHelper.validateDate(dateString)).toBe(true);
      expect(DateHelper.validateDate('4000-03-16')).toBe(false);
    });
  });
});
