Files
habitica/test/api/v3/integration/debug/POST-debug_make-admin.test.js
Phillip Thelen 3386d61fde fix debug tests
2024-06-19 17:30:52 +02:00

36 lines
778 B
JavaScript

import nconf from 'nconf';
import {
generateUser,
} from '../../../../helpers/api-integration/v3';
describe('POST /debug/make-admin', () => {
let user;
before(async () => {
user = await generateUser();
});
afterEach(() => {
nconf.set('IS_PROD', false);
});
it('makes user an admin', async () => {
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 () => {
sandbox.stub(nconf, 'get').withArgs('IS_PROD').returns(true);
await expect(user.post('/debug/make-admin'))
.eventually.be.rejected.and.to.deep.equal({
code: 404,
error: 'NotFound',
message: 'Not found.',
});
});
});