Skip to content

Commit

Permalink
fix(moment-date-adapter): relative date tests fixes (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
roll314 authored and pimenovoleg committed Mar 7, 2019
1 parent e7af9ca commit a16deb2
Showing 1 changed file with 31 additions and 10 deletions.
41 changes: 31 additions & 10 deletions src/mosaic-moment-adapter/adapter/moment-date-adapter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,9 @@ describe('MomentDateAdapter formatter', () => {
});

it('yesterday, less than 24 hours ago', () => {
const date = moment().subtract(23, 'hours');
const date = moment().subtract(23, 'hours')
.subtract(59, 'minutes')
.subtract(59, 'seconds');
expect(adapter.relativeShortDate(date)).toBe(`Вчера, ${date.format(TIME)}`);
});

Expand All @@ -509,7 +511,9 @@ describe('MomentDateAdapter formatter', () => {
});

it('before yesterday, less than 48 hours ago', () => {
const date = moment().subtract(47, 'hours');
const date = moment().subtract(47, 'hours')
.subtract(59, 'minutes')
.subtract(59, 'seconds');
expect(adapter.relativeShortDate(date)).toBe(
date.format(`${DAY}${NBSP}${SHORT_MONTH}, ${TIME}`)
);
Expand Down Expand Up @@ -545,7 +549,9 @@ describe('MomentDateAdapter formatter', () => {
});

it('yesterday, less than 24 hours ago', () => {
const date = moment().subtract(23, 'hours');
const date = moment().subtract(23, 'hours')
.subtract(59, 'minutes')
.subtract(59, 'seconds');
expect(adapter.relativeLongDate(date)).toBe(`Вчера, ${date.format(TIME)}`);
});

Expand All @@ -555,7 +561,9 @@ describe('MomentDateAdapter formatter', () => {
});

it('before yesterday, less than 48 hours ago', () => {
const date = moment().subtract(47, 'hours');
const date = moment().subtract(47, 'hours')
.subtract(59, 'minutes')
.subtract(59, 'seconds');
expect(adapter.relativeLongDate(date)).toBe(date.format(`${DAY_MONTH}, ${TIME}`));
});

Expand Down Expand Up @@ -1016,7 +1024,9 @@ describe('MomentDateAdapter formatter', () => {
});

it('yesterday, less than 24 hours ago', () => {
const date = moment().subtract(23, 'hours');
const date = moment().subtract(23, 'hours')
.subtract(59, 'minutes')
.subtract(59, 'seconds');
expect(adapter.relativeShortDate(date)).toBe(`Yesterday, ${date.format(TIME)}`);
});

Expand All @@ -1028,7 +1038,9 @@ describe('MomentDateAdapter formatter', () => {
});

it('before yesterday, less than 48 hours ago', () => {
const date = moment().subtract(47, 'hours');
const date = moment().subtract(47, 'hours')
.subtract(59, 'minutes')
.subtract(59, 'seconds');
expect(adapter.relativeShortDate(date)).toBe(
date.format(`${SHORT_MONTH}${NBSP}${DAY}, ${TIME}`)
);
Expand Down Expand Up @@ -1064,22 +1076,31 @@ describe('MomentDateAdapter formatter', () => {
});

it('yesterday, less than 24 hours ago', () => {
const date = moment().subtract(23, 'hours');
const date = moment().subtract(23, 'hours')
.subtract(59, 'minutes')
.subtract(59, 'seconds');

expect(adapter.relativeLongDate(date)).toBe(`Yesterday, ${date.format(TIME)}`);
});

it('before yesterday, more than 48 hours ago', () => {
const date = moment().subtract(49, 'hours');
const date = moment().subtract(49, 'hours')
.subtract(59, 'minutes')
.subtract(59, 'seconds');
expect(adapter.relativeLongDate(date)).toBe(date.format(`${DAY_MONTH}, ${TIME}`));
});

it('before yesterday, less than 48 hours ago', () => {
const date = moment().subtract(47, 'hours');
const date = moment().subtract(47, 'hours')
.subtract(59, 'minutes')
.subtract(59, 'seconds');
expect(adapter.relativeLongDate(date)).toBe(date.format(`${DAY_MONTH}, ${TIME}`));
});

it('before yesterday (other year)', () => {
const date = moment().year(2015).subtract(49, 'hours');
const date = moment().year(2015).subtract(49, 'hours')
.subtract(59, 'minutes')
.subtract(59, 'seconds');
expect(adapter.relativeLongDate(date)).toBe(date.format(`${DAY_MONTH}, ${YEAR}`));
});
});
Expand Down

0 comments on commit a16deb2

Please sign in to comment.