Skip to content

Commit

Permalink
fix(formatters): add all missing Date Formatters (#855)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding authored Dec 21, 2022
1 parent 30b80e2 commit 9d29e59
Show file tree
Hide file tree
Showing 14 changed files with 450 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Column } from '../../interfaces/index';
import { Formatters } from '../index';

describe('the DateEuroShort Formatter', () => {
it('should return null when no value is provided', () => {
const value = null;
const result = Formatters.dateEuroShort(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe(null);
});

it('should return original string when input value provided is not a valid date', () => {
const value = 'TBD';
const result = Formatters.dateEuroShort(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('TBD');
});

it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => {
const value = '2019-05-01 02:36:07';
const result = Formatters.dateEuroShort(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any);
expect(result).toBe('1/5/19');
});

it('should return a formatted date value in the morning when valid date value is provided', () => {
const value = new Date('2019-05-01T02:36:07');
const result = Formatters.dateEuroShort(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('1/5/19');
});

it('should return a formatted date value in the afternoon when valid date value is provided', () => {
const value = new Date('2019-05-01T20:36:07');
const result = Formatters.dateEuroShort(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('1/5/19');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Column } from '../../interfaces/index';
import { Formatters } from '../index';

describe('the DateTimeEuroAM_PM Formatter', () => {
it('should return null when no value is provided', () => {
const value = null;
const result = Formatters.dateTimeEuroAM_PM(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe(null);
});

it('should return original string when input value provided is not a valid date', () => {
const value = 'TBD';
const result = Formatters.dateTimeEuroAM_PM(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('TBD');
});

it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => {
const value = '2019-05-01 02:36:07';
const result = Formatters.dateTimeEuroAM_PM(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any);
expect(result).toBe('01/05/2019 02:36:07 AM');
});

it('should return a formatted date value in the morning when valid date value is provided', () => {
const value = new Date('2019-05-01T02:36:07');
const result = Formatters.dateTimeEuroAM_PM(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('01/05/2019 02:36:07 AM');
});

it('should return a formatted date value in the afternoon when valid date value is provided', () => {
const value = new Date('2019-05-01T20:36:07');
const result = Formatters.dateTimeEuroAM_PM(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('01/05/2019 08:36:07 PM');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Column } from '../../interfaces/index';
import { Formatters } from '../index';

describe('the DateTimeEuroShortAM_PM Formatter', () => {
it('should return null when no value is provided', () => {
const value = null;
const result = Formatters.dateTimeEuroShortAM_PM(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe(null);
});

it('should return original string when input value provided is not a valid date', () => {
const value = 'TBD';
const result = Formatters.dateTimeEuroShortAM_PM(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('TBD');
});

it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => {
const value = '2019-05-01 02:36:07';
const result = Formatters.dateTimeEuroShortAM_PM(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any);
expect(result).toBe('1/5/19 2:36:7 AM');
});

it('should return a formatted date value in the morning when valid date value is provided', () => {
const value = new Date('2019-05-01T02:36:07');
const result = Formatters.dateTimeEuroShortAM_PM(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('1/5/19 2:36:7 AM');
});

it('should return a formatted date value in the afternoon when valid date value is provided', () => {
const value = new Date('2019-05-01T20:36:07');
const result = Formatters.dateTimeEuroShortAM_PM(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('1/5/19 8:36:7 PM');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Column } from '../../interfaces/index';
import { Formatters } from '../index';

describe('the DateTimeEuroShortAmPm Formatter', () => {
it('should return null when no value is provided', () => {
const value = null;
const result = Formatters.dateTimeEuroShortAmPm(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe(null);
});

it('should return original string when input value provided is not a valid date', () => {
const value = 'TBD';
const result = Formatters.dateTimeEuroShortAmPm(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('TBD');
});

it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => {
const value = '2019-05-01 02:36:07';
const result = Formatters.dateTimeEuroShortAmPm(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any);
expect(result).toBe('1/5/19 2:36:7 am');
});

it('should return a formatted date value in the morning when valid date value is provided', () => {
const value = new Date('2019-05-01T02:36:07');
const result = Formatters.dateTimeEuroShortAmPm(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('1/5/19 2:36:7 am');
});

it('should return a formatted date value in the afternoon when valid date value is provided', () => {
const value = new Date('2019-05-01T20:36:07');
const result = Formatters.dateTimeEuroShortAmPm(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('1/5/19 8:36:7 pm');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Column } from '../../interfaces/index';
import { Formatters } from '../index';

describe('the DateTimeEuroShort Formatter', () => {
it('should return null when no value is provided', () => {
const value = null;
const result = Formatters.dateTimeEuroShort(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe(null);
});

it('should return original string when input value provided is not a valid date', () => {
const value = 'TBD';
const result = Formatters.dateTimeEuroShort(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('TBD');
});

it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => {
const value = '2019-05-01 02:36:07';
const result = Formatters.dateTimeEuroShort(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any);
expect(result).toBe('1/5/19 2:36:7');
});

it('should return a formatted date value in the morning when valid date value is provided', () => {
const value = new Date('2019-05-01T02:36:07');
const result = Formatters.dateTimeEuroShort(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('1/5/19 2:36:7');
});

it('should return a formatted date value in the afternoon when valid date value is provided', () => {
const value = new Date('2019-05-01T20:36:07');
const result = Formatters.dateTimeEuroShort(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('1/5/19 20:36:7');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Column } from '../../interfaces/index';
import { Formatters } from '../index';

describe('the DateTimeIsoAM_PM Formatter', () => {
it('should return null when no value is provided', () => {
const value = null;
const result = Formatters.dateTimeIsoAM_PM(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe(null);
});

it('should return original string when input value provided is not a valid date', () => {
const value = 'TBD';
const result = Formatters.dateTimeIsoAM_PM(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('TBD');
});

it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => {
const value = '2019-05-01 02:36:07';
const result = Formatters.dateTimeIsoAM_PM(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any);
expect(result).toBe('2019-05-01 02:36:07 AM');
});

it('should return a formatted date value in the morning when valid date value is provided', () => {
const value = new Date('2019-05-01T02:36:07');
const result = Formatters.dateTimeIsoAM_PM(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('2019-05-01 02:36:07 AM');
});

it('should return a formatted date value in the afternoon when valid date value is provided', () => {
const value = new Date('2019-05-01T20:36:07');
const result = Formatters.dateTimeIsoAM_PM(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('2019-05-01 08:36:07 PM');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Column } from '../../interfaces/index';
import { Formatters } from '../index';

describe('the DateTimeUsAM_PM Formatter', () => {
it('should return null when no value is provided', () => {
const value = null;
const result = Formatters.dateTimeUsAM_PM(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe(null);
});

it('should return original string when input value provided is not a valid date', () => {
const value = 'TBD';
const result = Formatters.dateTimeUsAM_PM(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('TBD');
});

it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => {
const value = '2019-05-01 02:36:07';
const result = Formatters.dateTimeUsAM_PM(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any);
expect(result).toBe('05/01/2019 02:36:07 AM');
});

it('should return a formatted date value in the morning when valid date value is provided', () => {
const value = new Date('2019-05-01T02:36:07');
const result = Formatters.dateTimeUsAM_PM(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('05/01/2019 02:36:07 AM');
});

it('should return a formatted date value in the afternoon when valid date value is provided', () => {
const value = new Date('2019-05-01T20:36:07');
const result = Formatters.dateTimeUsAM_PM(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('05/01/2019 08:36:07 PM');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Column } from '../../interfaces/index';
import { Formatters } from '../index';

describe('the DateTimeUsShortAM_PM Formatter', () => {
it('should return null when no value is provided', () => {
const value = null;
const result = Formatters.dateTimeUsShortAM_PM(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe(null);
});

it('should return original string when input value provided is not a valid date', () => {
const value = 'TBD';
const result = Formatters.dateTimeUsShortAM_PM(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('TBD');
});

it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => {
const value = '2019-05-01 02:36:07';
const result = Formatters.dateTimeUsShortAM_PM(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any);
expect(result).toBe('5/1/19 2:36:7 AM');
});

it('should return a formatted date value in the morning when valid date value is provided', () => {
const value = new Date('2019-05-01T02:36:07');
const result = Formatters.dateTimeUsShortAM_PM(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('5/1/19 2:36:7 AM');
});

it('should return a formatted date value in the afternoon when valid date value is provided', () => {
const value = new Date('2019-05-01T20:36:07');
const result = Formatters.dateTimeUsShortAM_PM(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('5/1/19 8:36:7 PM');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Column } from '../../interfaces/index';
import { Formatters } from '../index';

describe('the DateTimeUsShortAmPm Formatter', () => {
it('should return null when no value is provided', () => {
const value = null;
const result = Formatters.dateTimeUsShortAmPm(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe(null);
});

it('should return original string when input value provided is not a valid date', () => {
const value = 'TBD';
const result = Formatters.dateTimeUsShortAmPm(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('TBD');
});

it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => {
const value = '2019-05-01 02:36:07';
const result = Formatters.dateTimeUsShortAmPm(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any);
expect(result).toBe('5/1/19 2:36:7 am');
});

it('should return a formatted date value in the morning when valid date value is provided', () => {
const value = new Date('2019-05-01T02:36:07');
const result = Formatters.dateTimeUsShortAmPm(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('5/1/19 2:36:7 am');
});

it('should return a formatted date value in the afternoon when valid date value is provided', () => {
const value = new Date('2019-05-01T20:36:07');
const result = Formatters.dateTimeUsShortAmPm(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('5/1/19 8:36:7 pm');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Column } from '../../interfaces/index';
import { Formatters } from '../index';

describe('the DateTimeUsShort Formatter', () => {
it('should return null when no value is provided', () => {
const value = null;
const result = Formatters.dateTimeUsShort(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe(null);
});

it('should return original string when input value provided is not a valid date', () => {
const value = 'TBD';
const result = Formatters.dateTimeUsShort(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('TBD');
});

it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => {
const value = '2019-05-01 02:36:07';
const result = Formatters.dateTimeUsShort(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any);
expect(result).toBe('5/1/19 2:36:7');
});

it('should return a formatted date value in the morning when valid date value is provided', () => {
const value = new Date('2019-05-01T02:36:07');
const result = Formatters.dateTimeUsShort(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('5/1/19 2:36:7');
});

it('should return a formatted date value in the afternoon when valid date value is provided', () => {
const value = new Date('2019-05-01T20:36:07');
const result = Formatters.dateTimeUsShort(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('5/1/19 20:36:7');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Column } from '../../interfaces/index';
import { Formatters } from '../index';

describe('the DateUsShort Formatter', () => {
it('should return null when no value is provided', () => {
const value = null;
const result = Formatters.dateUsShort(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe(null);
});

it('should return original string when input value provided is not a valid date', () => {
const value = 'TBD';
const result = Formatters.dateUsShort(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('TBD');
});

it('should provide a dateIso formatted input and return a formatted date value without time when valid date value is provided', () => {
const value = '2019-05-01 02:36:07';
const result = Formatters.dateUsShort(0, 0, value, { type: 'dateIso' } as unknown as Column, {}, {} as any);
expect(result).toBe('5/1/19');
});

it('should return a formatted date value in the morning when valid date value is provided', () => {
const value = new Date('2019-05-01T02:36:07');
const result = Formatters.dateUsShort(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('5/1/19');
});

it('should return a formatted date value in the afternoon when valid date value is provided', () => {
const value = new Date('2019-05-01T20:36:07');
const result = Formatters.dateUsShort(0, 0, value, {} as Column, {}, {} as any);
expect(result).toBe('5/1/19');
});
});
Loading

0 comments on commit 9d29e59

Please sign in to comment.