mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-13 12:47:28 +01:00
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
import nconf from 'nconf';
|
|
import {
|
|
generateUser,
|
|
} from '../../../../helpers/api-integration/v3';
|
|
|
|
describe('GET /debug/time-travel-time', () => {
|
|
let user;
|
|
let nconfStub;
|
|
|
|
before(async () => {
|
|
user = await generateUser({ permissions: { fullAccess: true } });
|
|
});
|
|
|
|
beforeEach(() => {
|
|
nconfStub = sandbox.stub(nconf, 'get');
|
|
});
|
|
|
|
afterEach(() => {
|
|
nconfStub.restore();
|
|
});
|
|
|
|
it('returns the shifted time', async () => {
|
|
nconfStub.withArgs('TIME_TRAVEL_ENABLED').returns(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 shifted when the user is not an admin', async () => {
|
|
nconfStub.withArgs('TIME_TRAVEL_ENABLED').returns(true);
|
|
const regularUser = await generateUser();
|
|
const result = await regularUser.get('/debug/time-travel-time');
|
|
expect(result.time).to.exist;
|
|
});
|
|
|
|
it('returns error when not in time travel mode', async () => {
|
|
nconfStub.withArgs('TIME_TRAVEL_ENABLED').returns(false);
|
|
|
|
await expect(user.get('/debug/time-travel-time'))
|
|
.eventually.be.rejected.and.to.deep.equal({
|
|
code: 404,
|
|
error: 'NotFound',
|
|
message: 'Not found.',
|
|
});
|
|
});
|
|
});
|