From e9c1f125a545317c0ad3e0b67e9b0ba964e65333 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 18 Jan 2024 11:43:05 +0100 Subject: [PATCH] refs #6397 test back --- .../client/specs/createWithUser.spec.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/modules/client/back/methods/client/specs/createWithUser.spec.js b/modules/client/back/methods/client/specs/createWithUser.spec.js index 03106acc1..4191400e3 100644 --- a/modules/client/back/methods/client/specs/createWithUser.spec.js +++ b/modules/client/back/methods/client/specs/createWithUser.spec.js @@ -14,6 +14,8 @@ describe('Client Create', () => { provinceFk: 1 }; + const errorMail = `An email is necessary`; + beforeAll(async() => { const activeCtx = { 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); + 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`); + }); + it('should create a new account', async() => { const tx = await models.Client.beginTransaction({});