mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
fix date dependatent time travel test (#15285)
This commit is contained in:
@@ -34,9 +34,11 @@ describe('POST /debug/jump-time', () => {
|
|||||||
expect(resultDate.getMonth()).to.eql(today.getMonth());
|
expect(resultDate.getMonth()).to.eql(today.getMonth());
|
||||||
expect(resultDate.getFullYear()).to.eql(today.getFullYear());
|
expect(resultDate.getFullYear()).to.eql(today.getFullYear());
|
||||||
const newResultDate = new Date((await user.post('/debug/jump-time', { offsetDays: 1 })).time);
|
const newResultDate = new Date((await user.post('/debug/jump-time', { offsetDays: 1 })).time);
|
||||||
expect(newResultDate.getDate()).to.eql(today.getDate() + 1);
|
const tomorrow = new Date(today.valueOf());
|
||||||
expect(newResultDate.getMonth()).to.eql(today.getMonth());
|
tomorrow.setDate(today.getDate() + 1);
|
||||||
expect(newResultDate.getFullYear()).to.eql(today.getFullYear());
|
expect(newResultDate.getDate()).to.eql(tomorrow.getDate());
|
||||||
|
expect(newResultDate.getMonth()).to.eql(tomorrow.getMonth());
|
||||||
|
expect(newResultDate.getFullYear()).to.eql(tomorrow.getFullYear());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('jumps back', async () => {
|
it('jumps back', async () => {
|
||||||
@@ -45,9 +47,11 @@ describe('POST /debug/jump-time', () => {
|
|||||||
expect(resultDate.getMonth()).to.eql(today.getMonth());
|
expect(resultDate.getMonth()).to.eql(today.getMonth());
|
||||||
expect(resultDate.getFullYear()).to.eql(today.getFullYear());
|
expect(resultDate.getFullYear()).to.eql(today.getFullYear());
|
||||||
const newResultDate = new Date((await user.post('/debug/jump-time', { offsetDays: -1 })).time);
|
const newResultDate = new Date((await user.post('/debug/jump-time', { offsetDays: -1 })).time);
|
||||||
expect(newResultDate.getDate()).to.eql(today.getDate() - 1);
|
const yesterday = new Date(today.valueOf());
|
||||||
expect(newResultDate.getMonth()).to.eql(today.getMonth());
|
yesterday.setDate(today.getDate() - 1);
|
||||||
expect(newResultDate.getFullYear()).to.eql(today.getFullYear());
|
expect(newResultDate.getDate()).to.eql(yesterday.getDate());
|
||||||
|
expect(newResultDate.getMonth()).to.eql(yesterday.getMonth());
|
||||||
|
expect(newResultDate.getFullYear()).to.eql(yesterday.getFullYear());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can jump a lot', async () => {
|
it('can jump a lot', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user