exploratory-date.spec.ts 673 Bytes
Newer Older
sod-ext's avatar
sod-ext committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
describe('Explore the Date API', () => {
  it('should return the month of a Date', () => {
    const date = new Date('2020-10-06');
    const month = date.getUTCMonth();
    expect(month).toBe(9);
  });
  it('should return the hour of a Date', () => {
    const date = new Date('2020-10-06');
    const hour = date.getUTCHours();
    expect(hour).toBe(0);
  });
  it('should return the Date depending on timezone', () => {
    const date = new Date('2019-12-31T23:45:00Z');
    const day = date.getDate();
    const month = date.getMonth() + 1;
    const year = date.getFullYear();
    expect(day).toBe(1);
    expect(month).toBe(1);
    expect(year).toBe(2020);
  });
});