2022-01-09 14:51:50 -05:00
|
|
|
import { API_ERROR, HTTP_STATUS } from '../../../src/lib/constants';
|
2018-06-21 01:10:33 -05:00
|
|
|
|
2022-01-09 14:51:50 -05:00
|
|
|
export default function (server) {
|
2017-12-02 05:19:08 -05:00
|
|
|
describe('npm adduser', () => {
|
2017-04-19 14:15:28 -05:00
|
|
|
const user = String(Math.random());
|
|
|
|
const pass = String(Math.random());
|
2018-01-27 20:40:07 -05:00
|
|
|
|
2022-01-09 14:51:50 -05:00
|
|
|
beforeAll(function () {
|
|
|
|
return server
|
|
|
|
.auth(user, pass)
|
2019-07-16 01:40:01 -05:00
|
|
|
.status(HTTP_STATUS.CREATED)
|
|
|
|
.body_ok(/user .* created/);
|
2017-04-19 14:15:28 -05:00
|
|
|
});
|
2014-07-22 16:45:28 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test('should create new user', () => {});
|
2014-07-22 16:45:28 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test('should log in', () => {
|
2022-01-09 14:51:50 -05:00
|
|
|
return server
|
|
|
|
.auth(user, pass)
|
2019-07-16 01:40:01 -05:00
|
|
|
.status(HTTP_STATUS.CREATED)
|
|
|
|
.body_ok(/you are authenticated as/);
|
2017-04-19 14:15:28 -05:00
|
|
|
});
|
2014-07-22 16:45:28 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test('should not register more users', () => {
|
2022-01-09 14:51:50 -05:00
|
|
|
return server.auth(String(Math.random()), String(Math.random())).status(HTTP_STATUS.CONFLICT).body_error(API_ERROR.MAX_USERS_REACHED);
|
2017-04-19 14:15:28 -05:00
|
|
|
});
|
|
|
|
});
|
2017-12-02 05:19:08 -05:00
|
|
|
}
|