mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-10 01:52:04 +05:30
82 lines
1.7 KiB
TypeScript
82 lines
1.7 KiB
TypeScript
import expect from 'app/test/unexpected';
|
|
import sinon from 'sinon';
|
|
|
|
import request from 'app/services/request';
|
|
import signup from 'app/services/api/signup';
|
|
|
|
describe('signup api', () => {
|
|
describe('#register', () => {
|
|
const params = {
|
|
email: 'email',
|
|
username: 'username',
|
|
password: 'password',
|
|
rePassword: 'rePassword',
|
|
rulesAgreement: false,
|
|
lang: 'lang',
|
|
captcha: 'captcha',
|
|
};
|
|
|
|
beforeEach(() => {
|
|
sinon.stub(request, 'post').named('request.post');
|
|
});
|
|
|
|
afterEach(() => {
|
|
(request.post as any).restore();
|
|
});
|
|
|
|
it('should post to register api', () => {
|
|
signup.register(params);
|
|
|
|
expect(request.post, 'to have a call satisfying', [
|
|
'/api/signup',
|
|
params,
|
|
{},
|
|
]);
|
|
});
|
|
|
|
it('should disable any token', () => {
|
|
signup.register(params);
|
|
|
|
expect(request.post, 'to have a call satisfying', [
|
|
'/api/signup',
|
|
params,
|
|
{ token: null },
|
|
]);
|
|
});
|
|
});
|
|
|
|
describe('#activate', () => {
|
|
const params = {
|
|
key: 'key',
|
|
};
|
|
|
|
beforeEach(() => {
|
|
sinon.stub(request, 'post').named('request.post');
|
|
});
|
|
|
|
afterEach(() => {
|
|
(request.post as any).restore();
|
|
});
|
|
|
|
it('should post to confirmation api', () => {
|
|
signup.activate(params);
|
|
|
|
expect(request.post, 'to have a call satisfying', [
|
|
'/api/signup/confirm',
|
|
params,
|
|
{},
|
|
]);
|
|
});
|
|
|
|
it('should disable any token', () => {
|
|
signup.activate(params);
|
|
|
|
expect(request.post, 'to have a call satisfying', [
|
|
'/api/signup/confirm',
|
|
params,
|
|
{ token: null },
|
|
]);
|
|
});
|
|
});
|
|
});
|