mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 05:07:22 +01:00
Fix various tests
This commit is contained in:
committed by
Sabe Jones
parent
3540a274b3
commit
fb56f7df20
@@ -0,0 +1,44 @@
|
||||
import nconf from 'nconf';
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../../../helpers/api-integration/v3';
|
||||
|
||||
describe('GET /debug/time-travel-time', () => {
|
||||
let user;
|
||||
before(async () => {
|
||||
user = await generateUser({ permissions: { fullAccess: true } });
|
||||
});
|
||||
|
||||
after(() => {
|
||||
nconf.set('ENABLE_TIME_TRAVEL', false);
|
||||
});
|
||||
|
||||
it('returns the shifted time', async () => {
|
||||
nconf.set('ENABLE_TIME_TRAVEL', true);
|
||||
const result = await user.get('/debug/time-travel-time');
|
||||
expect(result.time).to.exist;
|
||||
await user.post('/debug/jump-time', { disable: true });
|
||||
});
|
||||
|
||||
it('returns error when the user is not an admin', async () => {
|
||||
nconf.set('ENABLE_TIME_TRAVEL', true);
|
||||
const regularUser = await generateUser();
|
||||
await expect(regularUser.get('/debug/time-travel-time'))
|
||||
.eventually.be.rejected.and.to.deep.equal({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: 'You do not have permission to time travel.',
|
||||
});
|
||||
});
|
||||
|
||||
it('returns error when not in time travel mode', async () => {
|
||||
nconf.set('ENABLE_TIME_TRAVEL', false);
|
||||
|
||||
await expect(user.get('/debug/time-travel-time'))
|
||||
.eventually.be.rejected.and.to.deep.equal({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: 'Not found.',
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user