refs #6397 emailValidation #1941
|
@ -14,6 +14,8 @@ describe('Client Create', () => {
|
||||||
provinceFk: 1
|
provinceFk: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
carlossa marked this conversation as resolved
Outdated
|
|||||||
|
const errorMail = `An email is necessary`;
|
||||||
|
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
const activeCtx = {
|
const activeCtx = {
|
||||||
accessToken: {userId: 9},
|
accessToken: {userId: 9},
|
||||||
|
@ -48,6 +50,31 @@ describe('Client Create', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not create a new account', async() => {
|
||||||
|
const tx = await models.Client.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
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);
|
||||||
carlossa marked this conversation as resolved
alexm
commented
La estructura no esta correcta, deuria ser:
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');
```
|
|||||||
|
expect(client.socialName).toEqual(newAccount.socialName);
|
||||||
|
expect(client.businessTypeFk).toEqual(newAccount.businessTypeFk);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(errorMail).toEqual(`An email is necessary`);
|
||||||
carlossa marked this conversation as resolved
Outdated
alexm
commented
Si te has definido la variable, siempre va a dar lo mismo. 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() => {
|
it('should create a new account', async() => {
|
||||||
const tx = await models.Client.beginTransaction({});
|
const tx = await models.Client.beginTransaction({});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
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