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';
|
2020-01-18 02:07:52 +05:30
|
|
|
import * as 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', () => {
|
2020-01-18 02:07:52 +05:30
|
|
|
const 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', () => {
|
2020-01-18 02:07:52 +05:30
|
|
|
signup.activate(key);
|
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',
|
2020-01-18 02:07:52 +05:30
|
|
|
{ key },
|
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 disable any token', () => {
|
2020-01-18 02:07:52 +05:30
|
|
|
signup.activate(key);
|
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',
|
2020-01-18 02:07:52 +05:30
|
|
|
{ key },
|
2019-11-27 14:33:32 +05:30
|
|
|
{ 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
|
|
|
});
|