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', () => {
|
2020-05-24 04:38:24 +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
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
sinon.stub(request, 'post').named('request.post');
|
|
|
|
});
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
afterEach(() => {
|
|
|
|
(request.post as any).restore();
|
|
|
|
});
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
it('should post to register api', () => {
|
|
|
|
signup.register(params);
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
expect(request.post, 'to have a call satisfying', ['/api/signup', params, {}]);
|
|
|
|
});
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
it('should disable any token', () => {
|
|
|
|
signup.register(params);
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
expect(request.post, 'to have a call satisfying', ['/api/signup', params, { token: null }]);
|
|
|
|
});
|
2016-12-25 23:39:47 +05:30
|
|
|
});
|
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
describe('#activate', () => {
|
|
|
|
const key = 'key';
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
sinon.stub(request, 'post').named('request.post');
|
|
|
|
});
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
afterEach(() => {
|
|
|
|
(request.post as any).restore();
|
|
|
|
});
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
it('should post to confirmation api', () => {
|
|
|
|
signup.activate(key);
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
expect(request.post, 'to have a call satisfying', ['/api/signup/confirm', { key }, {}]);
|
|
|
|
});
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
it('should disable any token', () => {
|
|
|
|
signup.activate(key);
|
2016-12-25 23:39:47 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
expect(request.post, 'to have a call satisfying', ['/api/signup/confirm', { key }, { token: null }]);
|
|
|
|
});
|
2016-12-25 23:39:47 +05:30
|
|
|
});
|
|
|
|
});
|