1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-10-06 22:17:10 +02:00

Tools: Fixed tests

This commit is contained in:
Laurent Cozic
2021-06-10 11:13:00 +02:00
parent b2b6ad479a
commit c37eb56ed7
2 changed files with 15 additions and 3 deletions

View File

@@ -1,8 +1,10 @@
import config from '../../config';
import { NotificationKey } from '../../models/NotificationModel'; import { NotificationKey } from '../../models/NotificationModel';
import { AccountType } from '../../models/UserModel'; import { AccountType } from '../../models/UserModel';
import { MB } from '../../utils/bytes'; import { MB } from '../../utils/bytes';
import { execRequestC } from '../../utils/testing/apiUtils'; import { execRequestC } from '../../utils/testing/apiUtils';
import { beforeAllDb, afterAllTests, beforeEachDb, models } from '../../utils/testing/testUtils'; import { beforeAllDb, afterAllTests, beforeEachDb, models } from '../../utils/testing/testUtils';
import { FormUser } from './signup';
describe('index_signup', function() { describe('index_signup', function() {
@@ -19,12 +21,22 @@ describe('index_signup', function() {
}); });
test('should create a new account', async function() { test('should create a new account', async function() {
const context = await execRequestC('', 'POST', 'signup', { const formUser: FormUser = {
full_name: 'Toto', full_name: 'Toto',
email: 'toto@example.com', email: 'toto@example.com',
password: 'testing', password: 'testing',
password2: 'testing', password2: 'testing',
}); };
// First confirm that it doesn't work if sign up is disabled
{
config().signupEnabled = false;
await execRequestC('', 'POST', 'signup', formUser);
expect(await models().user().loadByEmail('toto@example.com')).toBeFalsy();
}
config().signupEnabled = true;
const context = await execRequestC('', 'POST', 'signup', formUser);
// Check that the user has been created // Check that the user has been created
const user = await models().user().loadByEmail('toto@example.com'); const user = await models().user().loadByEmail('toto@example.com');

View File

@@ -21,7 +21,7 @@ function makeView(error: Error = null): View {
return view; return view;
} }
interface FormUser { export interface FormUser {
full_name: string; full_name: string;
email: string; email: string;
password: string; password: string;