accounts-frontend/packages/app/services/api/activate.test.ts

64 lines
1.7 KiB
TypeScript
Raw Normal View History

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