2019-06-30 19:02:50 +05:30
|
|
|
import expect from 'test/unexpected';
|
2016-12-25 23:39:47 +05:30
|
|
|
import sinon from 'sinon';
|
|
|
|
|
|
|
|
import request from 'services/request';
|
|
|
|
import signup from 'services/api/signup';
|
|
|
|
|
|
|
|
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(() => {
|
|
|
|
request.post.restore();
|
|
|
|
});
|
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(() => {
|
|
|
|
request.post.restore();
|
|
|
|
});
|
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
|
|
|
});
|