mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +01:00
integration fix
This commit is contained in:
@@ -15,6 +15,7 @@ describe('POST /debug/jump-time', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
nconfStub = sandbox.stub(nconf, 'get');
|
nconfStub = sandbox.stub(nconf, 'get');
|
||||||
|
nconfStub.withArgs('TIME_TRAVEL_ENABLED').returns(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@@ -28,7 +29,6 @@ describe('POST /debug/jump-time', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Jumps forward', async () => {
|
it('Jumps forward', async () => {
|
||||||
nconf.set('TIME_TRAVEL_ENABLED', true);
|
|
||||||
const resultDate = new Date((await user.post('/debug/jump-time', { reset: true })).time);
|
const resultDate = new Date((await user.post('/debug/jump-time', { reset: true })).time);
|
||||||
expect(resultDate.getDate()).to.eql(today.getDate());
|
expect(resultDate.getDate()).to.eql(today.getDate());
|
||||||
expect(resultDate.getMonth()).to.eql(today.getMonth());
|
expect(resultDate.getMonth()).to.eql(today.getMonth());
|
||||||
@@ -40,7 +40,6 @@ describe('POST /debug/jump-time', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('jumps back', async () => {
|
it('jumps back', async () => {
|
||||||
nconf.set('TIME_TRAVEL_ENABLED', true);
|
|
||||||
const resultDate = new Date((await user.post('/debug/jump-time', { reset: true })).time);
|
const resultDate = new Date((await user.post('/debug/jump-time', { reset: true })).time);
|
||||||
expect(resultDate.getDate()).to.eql(today.getDate());
|
expect(resultDate.getDate()).to.eql(today.getDate());
|
||||||
expect(resultDate.getMonth()).to.eql(today.getMonth());
|
expect(resultDate.getMonth()).to.eql(today.getMonth());
|
||||||
@@ -52,7 +51,6 @@ describe('POST /debug/jump-time', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can jump a lot', async () => {
|
it('can jump a lot', async () => {
|
||||||
nconf.set('TIME_TRAVEL_ENABLED', true);
|
|
||||||
const resultDate = new Date((await user.post('/debug/jump-time', { reset: true })).time);
|
const resultDate = new Date((await user.post('/debug/jump-time', { reset: true })).time);
|
||||||
expect(resultDate.getDate()).to.eql(today.getDate());
|
expect(resultDate.getDate()).to.eql(today.getDate());
|
||||||
expect(resultDate.getMonth()).to.eql(today.getMonth());
|
expect(resultDate.getMonth()).to.eql(today.getMonth());
|
||||||
@@ -62,7 +60,6 @@ describe('POST /debug/jump-time', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns error when the user is not an admin', async () => {
|
it('returns error when the user is not an admin', async () => {
|
||||||
nconf.set('TIME_TRAVEL_ENABLED', true);
|
|
||||||
const regularUser = await generateUser();
|
const regularUser = await generateUser();
|
||||||
await expect(regularUser.post('/debug/jump-time', { offsetDays: 1 }))
|
await expect(regularUser.post('/debug/jump-time', { offsetDays: 1 }))
|
||||||
.eventually.be.rejected.and.to.deep.equal({
|
.eventually.be.rejected.and.to.deep.equal({
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ const { content } = shared;
|
|||||||
|
|
||||||
describe('POST /user/buy/:key', () => {
|
describe('POST /user/buy/:key', () => {
|
||||||
let user;
|
let user;
|
||||||
|
let clock;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
user = await generateUser({
|
user = await generateUser({
|
||||||
@@ -18,6 +19,12 @@ describe('POST /user/buy/:key', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
if (clock) {
|
||||||
|
clock.restore();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// More tests in common code unit tests
|
// More tests in common code unit tests
|
||||||
|
|
||||||
it('returns an error if the item is not found', async () => {
|
it('returns an error if the item is not found', async () => {
|
||||||
@@ -68,6 +75,7 @@ describe('POST /user/buy/:key', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('buys a special spell', async () => {
|
it('buys a special spell', async () => {
|
||||||
|
clock = sinon.useFakeTimers(new Date('2024-10-31T00:00:00Z'));
|
||||||
const key = 'spookySparkles';
|
const key = 'spookySparkles';
|
||||||
const item = content.special[key];
|
const item = content.special[key];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user