refs #6397 emailValidation #1941

Merged
carlossa merged 13 commits from 6397-emailValidation into dev 2024-02-01 17:45:54 +00:00
1 changed files with 16 additions and 16 deletions
Showing only changes of commit 391f418883 - Show all commits

View File

@ -13,8 +13,16 @@ describe('Client Create', () => {
businessTypeFk: 'florist',
provinceFk: 1
};
const errorMail = `An email is necessary`;
const newAccount2 = {
carlossa marked this conversation as resolved Outdated
Outdated
Review

Si vas a gasstar dos vegades lo mateix pero canviant un parametre.
Pots fer clonarte el objecte i modficar soles lo que vols
Teu vaig dir en persona

Si vas a gasstar dos vegades lo mateix pero canviant un parametre. Pots fer clonarte el objecte i modficar soles lo que vols Teu vaig dir en persona
userName: 'Deadpool',
fi: '16195279J',
name: 'Wade',
socialName: 'DEADPOOL MARVEL',
street: 'WALL STREET',
city: 'New York',
businessTypeFk: 'florist',
provinceFk: 1
};
beforeAll(async() => {
const activeCtx = {
@ -53,26 +61,18 @@ describe('Client Create', () => {
it('should not create a new account', async() => {
const tx = await models.Client.beginTransaction({});
let error;
try {
carlossa marked this conversation as resolved
Review

La estructura no esta correcta, deuria ser:

         try{
            await funcioQueVolsProbar()
            await tx.rollback();
        } catch (e) {
            await tx.rollback();
            error = e;
        }

        expect(error.message).toEqual('Error que esperes');
La estructura no esta correcta, deuria ser: ``` try{ await funcioQueVolsProbar() await tx.rollback(); } catch (e) { await tx.rollback(); error = e; } expect(error.message).toEqual('Error que esperes'); ```
const options = {transaction: tx};
const client = await models.Client.createWithUser(newAccount, options);
const account = await models.VnUser.findOne({where: {name: newAccount.userName}}, options);
expect(account.name).toEqual(newAccount.userName);
expect(client.id).toEqual(account.id);
expect(client.name).toEqual(newAccount.name);
expect(client.fi).toEqual(newAccount.fi);
expect(client.socialName).toEqual(newAccount.socialName);
expect(client.businessTypeFk).toEqual(newAccount.businessTypeFk);
await models.Client.createWithUser(newAccount2, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
error = e.message;
expect(errorMail).toEqual(`An email is necessary`);
expect(error).toEqual(`An email is necessary`);
await tx.rollback();
}
carlossa marked this conversation as resolved Outdated
Outdated
Review

Si te has definido la variable, siempre va a dar lo mismo.
Deberias guardarte el error que te de y comprobarlo

Si te has definido la variable, siempre va a dar lo mismo. Deberias guardarte el error que te de y comprobarlo
});
it('should create a new account', async() => {