2019-12-08 00:32:00 +05:30
|
|
|
import expect from 'app/test/unexpected';
|
2016-12-25 23:39:47 +05:30
|
|
|
import sinon from 'sinon';
|
|
|
|
|
2019-12-08 00:32:00 +05:30
|
|
|
import request from 'app/services/request';
|
|
|
|
import signup from 'app/services/api/signup';
|
2016-12-25 23:39:47 +05:30
|
|
|
|
|
|
|
describe('signup api', () => {
|
2019-11-27 14:33:32 +05:30
|
|
|
describe('#register', () => {
|
|
|
|
const params = {
|
|
|
|
email: 'email',
|
|
|
|
username: 'username',
|
|
|
|
password: 'password',
|
|
|
|
rePassword: 'rePassword',
|
|
|
|
rulesAgreement: false,
|
|
|
|
lang: 'lang',
|
|
|
|
captcha: 'captcha',
|
|
|
|
};
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
sinon.stub(request, 'post').named('request.post');
|
|
|
|
});
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
afterEach(() => {
|
2019-12-07 16:58:52 +05:30
|
|
|
(request.post as any).restore();
|
2019-11-27 14:33:32 +05:30
|
|
|
});
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
it('should post to register api', () => {
|
|
|
|
signup.register(params);
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
expect(request.post, 'to have a call satisfying', [
|
|
|
|
'/api/signup',
|
|
|
|
params,
|
|
|
|
{},
|
|
|
|
]);
|
|
|
|
});
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
it('should disable any token', () => {
|
|
|
|
signup.register(params);
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
expect(request.post, 'to have a call satisfying', [
|
|
|
|
'/api/signup',
|
|
|
|
params,
|
|
|
|
{ token: null },
|
|
|
|
]);
|
2016-12-25 23:39:47 +05:30
|
|
|
});
|
2019-11-27 14:33:32 +05:30
|
|
|
});
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
describe('#activate', () => {
|
|
|
|
const params = {
|
|
|
|
key: 'key',
|
|
|
|
};
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
sinon.stub(request, 'post').named('request.post');
|
|
|
|
});
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
afterEach(() => {
|
2019-12-07 16:58:52 +05:30
|
|
|
(request.post as any).restore();
|
2019-11-27 14:33:32 +05:30
|
|
|
});
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
it('should post to confirmation api', () => {
|
|
|
|
signup.activate(params);
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
expect(request.post, 'to have a call satisfying', [
|
|
|
|
'/api/signup/confirm',
|
|
|
|
params,
|
|
|
|
{},
|
|
|
|
]);
|
|
|
|
});
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
it('should disable any token', () => {
|
|
|
|
signup.activate(params);
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
expect(request.post, 'to have a call satisfying', [
|
|
|
|
'/api/signup/confirm',
|
|
|
|
params,
|
|
|
|
{ token: null },
|
|
|
|
]);
|
2016-12-25 23:39:47 +05:30
|
|
|
});
|
2019-11-27 14:33:32 +05:30
|
|
|
});
|
2016-12-25 23:39:47 +05:30
|
|
|
});
|