mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 05:07:22 +01:00
43 lines
971 B
JavaScript
43 lines
971 B
JavaScript
import nconf from 'nconf';
|
|
import {
|
|
generateUser,
|
|
} from '../../../../helpers/api-integration/v3';
|
|
|
|
describe('POST /debug/make-admin', () => {
|
|
let user;
|
|
let nconfStub;
|
|
|
|
before(async () => {
|
|
user = await generateUser();
|
|
});
|
|
|
|
beforeEach(() => {
|
|
nconfStub = sandbox.stub(nconf, 'get');
|
|
nconfStub.withArgs('BASE_URL').returns('https://example.com');
|
|
});
|
|
|
|
afterEach(() => {
|
|
nconfStub.restore();
|
|
});
|
|
|
|
it('makes user an admin', async () => {
|
|
nconfStub.withArgs('DEBUG_ENABLED').returns(true);
|
|
await user.post('/debug/make-admin');
|
|
|
|
await user.sync();
|
|
|
|
expect(user.permissions.fullAccess).to.eql(true);
|
|
});
|
|
|
|
it('returns error when not in production mode', async () => {
|
|
nconfStub.withArgs('DEBUG_ENABLED').returns(false);
|
|
|
|
await expect(user.post('/debug/make-admin'))
|
|
.eventually.be.rejected.and.to.deep.equal({
|
|
code: 404,
|
|
error: 'NotFound',
|
|
message: 'Not found.',
|
|
});
|
|
});
|
|
});
|