Skip to content

Commit

Permalink
Tools: Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent22 committed Jun 10, 2021
1 parent b2b6ad4 commit c37eb56
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions packages/server/src/routes/index/signup.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import config from '../../config';
import { NotificationKey } from '../../models/NotificationModel';
import { AccountType } from '../../models/UserModel';
import { MB } from '../../utils/bytes';
import { execRequestC } from '../../utils/testing/apiUtils';
import { beforeAllDb, afterAllTests, beforeEachDb, models } from '../../utils/testing/testUtils';
import { FormUser } from './signup';

describe('index_signup', function() {

Expand All @@ -19,12 +21,22 @@ describe('index_signup', function() {
});

test('should create a new account', async function() {
const context = await execRequestC('', 'POST', 'signup', {
const formUser: FormUser = {
full_name: 'Toto',
email: '[email protected]',
password: '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('[email protected]')).toBeFalsy();
}

config().signupEnabled = true;
const context = await execRequestC('', 'POST', 'signup', formUser);

// Check that the user has been created
const user = await models().user().loadByEmail('[email protected]');
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/routes/index/signup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function makeView(error: Error = null): View {
return view;
}

interface FormUser {
export interface FormUser {
full_name: string;
email: string;
password: string;
Expand Down

0 comments on commit c37eb56

Please sign in to comment.