forked from sombochea/verdaccio-ui
test: fix formatDateDistance test (#43)
Test formatDateDistance with a date which is about 2 months in the past and another which is exactly 2 months in the past.
This commit is contained in:
parent
9d7be476ad
commit
c3eac3d27b
@ -52,13 +52,21 @@ describe('formatDate', () => {
|
|||||||
|
|
||||||
describe('formatDateDistance', () => {
|
describe('formatDateDistance', () => {
|
||||||
test('should calculate the distance', () => {
|
test('should calculate the distance', () => {
|
||||||
|
const dateAboutTwoMonthsAgo = () => {
|
||||||
|
const date = new Date();
|
||||||
|
date.setMonth(date.getMonth() - 1);
|
||||||
|
date.setDate(date.getDay() - 20);
|
||||||
|
return date;
|
||||||
|
};
|
||||||
const dateTwoMonthsAgo = () => {
|
const dateTwoMonthsAgo = () => {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
date.setMonth(date.getMonth() - 2);
|
date.setMonth(date.getMonth() - 2);
|
||||||
return date;
|
return date;
|
||||||
};
|
};
|
||||||
const date = dateTwoMonthsAgo();
|
const date1 = dateAboutTwoMonthsAgo();
|
||||||
expect(formatDateDistance(date)).toEqual('about 2 months');
|
const date2 = dateTwoMonthsAgo();
|
||||||
|
expect(formatDateDistance(date1)).toEqual('about 2 months');
|
||||||
|
expect(formatDateDistance(date2)).toEqual('2 months');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user