From 0e3d568743828a0ea01ff6c06504b9fe13fe0d1e Mon Sep 17 00:00:00 2001 From: Gerard Date: Wed, 6 Mar 2019 14:06:36 +0100 Subject: [PATCH 1/3] #1218 ticket.new quitar restricciones al crear un ticket abono --- modules/ticket/back/methods/ticket/new.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/ticket/back/methods/ticket/new.js b/modules/ticket/back/methods/ticket/new.js index a1a53ca3b..db25fe715 100644 --- a/modules/ticket/back/methods/ticket/new.js +++ b/modules/ticket/back/methods/ticket/new.js @@ -36,10 +36,14 @@ module.exports = Self => { ] }); - {if (!address) - throw new UserError(`This address doesn't exist`);} + if (!address) + throw new UserError(`This address doesn't exist`); - if (address.client().type().code === 'normal') { + let agency; + if (params && params.agencyModeFk) + agency = await Self.app.models.AgencyMode.findById(params.agencyModeFk); + + if (address.client().type().code === 'normal' && (!agency || agency.code != 'refund')) { if (address.client().isFreezed) throw new UserError(`You can't create a ticket for a frozen client`); @@ -54,10 +58,6 @@ module.exports = Self => { throw new UserError(`You can't create a ticket for a client that has a debt`); } - let agency; - if (params.agencyModeFk) - agency = await Self.app.models.AgencyMode.findById(params.agencyModeFk); - if (!params.shipped && params.landed) { params.shipped = await Self.app.models.Agency.getShipped({ landed: params.landed, From af960e5f5f6ae5cba29195ec27347bfad8a6424e Mon Sep 17 00:00:00 2001 From: Gerard Date: Wed, 6 Mar 2019 16:28:09 +0100 Subject: [PATCH 2/3] fonts updated to 1.26 version --- front/core/styles/salixfont.css | 13 ++++++++----- front/core/styles/salixfont.svg | 1 + front/core/styles/salixfont.ttf | Bin 23724 -> 23996 bytes front/core/styles/salixfont.woff | Bin 23800 -> 24072 bytes modules/client/front/routes.json | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/front/core/styles/salixfont.css b/front/core/styles/salixfont.css index 8e9a02963..dc0703edb 100644 --- a/front/core/styles/salixfont.css +++ b/front/core/styles/salixfont.css @@ -23,8 +23,8 @@ -moz-osx-font-smoothing: grayscale; } -.icon-pets:before { - content: "\e94e"; +.icon-unavailable:before { + content: "\e94f"; } .icon-100:before { content: "\e940"; @@ -134,12 +134,12 @@ .icon-info:before { content: "\e949"; } -.icon-invoices1:before { - content: "\e94a"; -} .icon-invoices:before { content: "\e91c"; } +.icon-invoices1:before { + content: "\e94a"; +} .icon-item:before { content: "\e941"; } @@ -191,6 +191,9 @@ .icon-person:before { content: "\e929"; } +.icon-pets:before { + content: "\e94e"; +} .icon-photo:before { content: "\e92a"; } diff --git a/front/core/styles/salixfont.svg b/front/core/styles/salixfont.svg index d6654ec1e..2e3395047 100644 --- a/front/core/styles/salixfont.svg +++ b/front/core/styles/salixfont.svg @@ -86,4 +86,5 @@ + \ No newline at end of file diff --git a/front/core/styles/salixfont.ttf b/front/core/styles/salixfont.ttf index 7c0ac2492e9e53d1af4eb16ed47a939da5cb585b..291a7be49bf762f2b25ee4400c5c103eb418c82f 100644 GIT binary patch delta 554 zcmZ3plX1^(#(D-u1_lOhh6V;^1_S?KeItG$wql^j9w1Ig&P^;354&`Yfq_v5$PYmAVtjbNSC}1dJJPhRD0rC~{5_41I!f(0* z`G0^K<`v`@mjE3K1hI1_?r>-HpTy|R=)c*A(J;K8lY!y?0Tu@413(4rKp%-R$S}Av zcrgSrgaWk+Dhsj$F{7!nD7&e$fv60lsEDYls2roXDLX%-k(sfPn5YPwvXYvq4WlVL zP?%krUEJK%T#nJ$$lQ+6+|1NOO&w&4u`0W+cLpPvQ;9m>V^1n*O#c9m!y39=LK_&vj1{9+}EIMQE^>}`puMFHQpb%rYv2@BD v7(IDGggIl#<{J?{jFT0j)`;k^0cAk?LKqJ+$bwWcFioBqBfR;2)Lupa@tS>t delta 284 zcmdn9n{mxf#(D-u1_lOhh6V;^1_S?KeItG$wj!X&9w1Ig&P^;354&`gfq_v5$PYFLv9yJ?U_8IgR|aktkUEAN uo!b;)^yC$h=8VCcA4K{vPBw^MAprJ!Fylc6S+G*3$qQqJH~){`%Lo8e6Gr3! diff --git a/front/core/styles/salixfont.woff b/front/core/styles/salixfont.woff index 2a9a880f52056e7351bcdcfa84e5312fba9b60ee..60b4ccb9310f4cea1b6253a9a043441f4e39b7ef 100644 GIT binary patch delta 576 zcmeydld)qDqgc7Wn;Qco0}#YYzA?8eA(G$%h9sLn3B2B>Hi2p8^*waHDa09qWQ0pu%y zaS`L;yu{p8pqK|x<2(?K3%}`JkY8K^^v8>dfBYH!C;KpZGx~3y!Dtv>&&j~>{{RaE z^8p5C26mutMHyrmTp7F=0vSSqdIgmQ*@2kRR9TeWRM|jOhEY^RR8>@tQQVZBpV7$7 z*hoxNgiTpV&D4g`lpQF{uFNiOZfY*aXl!I|$7pV5YNDnNGR0Vx-Pl}@(Ueh~QJwK> zhqgA8kakogqj|lQu5eVO0~;@!LuiDpZG;P(s4$PzGUH{OvR+zx8X8uD0;!&Vr$)&! zW><)%F*7oLxA|jZ!^F#&|BqLnN$KxqCPAC@$ODp+{)R?IuG+jR!Y3l599SZ3LB_H1 zvb)Ndi1DsAUMru85bfnf)VaUd3*G52~r xzs*+$ZWf>b1H+A_Q|7?v$!{Xe8ACR!MEWpJ&WT#XrNai40qG0bEEj!?5de(!f2#lh delta 306 zcmeC!!}wz-qgc7Wn;Qco0}#agVBiMRYZw?Oe~cBIs3Tlol$@Jbz`($m0h9;A&?1HvAndw1)+RTx0?3b+0P+>U zxRCL1USe)4P|O0TaUKZAh2L~9$S*Dd`sc>PKmLq Date: Thu, 7 Mar 2019 07:51:29 +0100 Subject: [PATCH 3/3] cau 10041 update fixtures for workers and fix test --- db/install/dump/fixtures.sql | 39 ++++++++---- .../back/methods/client/isValidClient.js | 19 +++--- .../client/specs/isValidClient.spec.js | 60 ++++++++----------- 3 files changed, 61 insertions(+), 57 deletions(-) diff --git a/db/install/dump/fixtures.sql b/db/install/dump/fixtures.sql index 2488c231b..ea867559a 100644 --- a/db/install/dump/fixtures.sql +++ b/db/install/dump/fixtures.sql @@ -191,18 +191,23 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`) INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`fax`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`,`mailAddress`,`cplusTerIdNifFk`,`hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`) VALUES - (101, 'Bruce Wayne', '84612325V', 'Batman', 'Alfred', '1007 Mountain Drive, Gotham', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'BruceWayne@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1), - (102, 'Petter Parker', '87945234L', 'Spider-Man', 'Aunt May', '20 Ingram Street', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'PetterParker@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 0, 1, NULL, 0, 0, 18, 0, 1), - (103, 'Clark Kent', '06815934E', 'Super-Man', 'lois lane', '344 Clinton Street', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'ClarkKent@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 0, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1), - (104, 'Tony Stark', '06089160W', 'Iron-Man', 'Pepper Potts', '10880 Malibu Point', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'TonyStark@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1), - (105, 'Max Eisenhardt', '39182496H', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'MaxEisenhardt@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, NULL, 0, 1), - (106, 'DavidCharlesHaller', '53136686Q', 'Legion', 'Charles Xavier', 'Evil hideout', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'DavidCharlesHaller@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1), - (107, 'Hank Pym', '09854837G', 'Ant-Man', 'Hawk', 'Anthill', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'HankPym@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1), - (108, 'Charles Xavier', '22641921P', 'Professor X', 'Beast', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'CharlesXavier@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1), - (109, 'Bruce Banner', '16104829E', 'Hulk', 'Black widow', 'Somewhere in New York', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'BruceBanner@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 0, 1, NULL, 0, 0, 19, 0, 1), - (110, 'Jessica Jones', '58282869H', 'Jessica Jones', 'Luke Cage', 'NYCC 2015 Poster', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'JessicaJones@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 0, 1, NULL, 0, 0, NULL, 0, 1), - (200, 'Missing', NULL, 'Missing man', 'Anton', 'The space', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 4, NULL, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1), - (400, 'Trash', NULL, 'Garbage man', 'Unknown name', 'New York city', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 4, NULL, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1); + (101, 'Bruce Wayne', '84612325V', 'Batman', 'Alfred', '1007 Mountain Drive, Gotham', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'BruceWayne@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1), + (102, 'Petter Parker', '87945234L', 'Spider-Man', 'Aunt May', '20 Ingram Street', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'PetterParker@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 0, 1, NULL, 0, 0, 18, 0, 1), + (103, 'Clark Kent', '06815934E', 'Super-Man', 'lois lane', '344 Clinton Street', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'ClarkKent@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 0, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1), + (104, 'Tony Stark', '06089160W', 'Iron-Man', 'Pepper Potts', '10880 Malibu Point', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'TonyStark@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1), + (105, 'Max Eisenhardt', '39182496H', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'MaxEisenhardt@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, NULL, 0, 1), + (106, 'DavidCharlesHaller', '53136686Q', 'Legion', 'Charles Xavier', 'Evil hideout', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'DavidCharlesHaller@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1), + (107, 'Hank Pym', '09854837G', 'Ant-Man', 'Hawk', 'Anthill', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'HankPym@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1), + (108, 'Charles Xavier', '22641921P', 'Professor X', 'Beast', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'CharlesXavier@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1), + (109, 'Bruce Banner', '16104829E', 'Hulk', 'Black widow', 'Somewhere in New York', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'BruceBanner@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 0, 1, NULL, 0, 0, 19, 0, 1), + (110, 'Jessica Jones', '58282869H', 'Jessica Jones', 'Luke Cage', 'NYCC 2015 Poster', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'JessicaJones@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 0, 1, NULL, 0, 0, NULL, 0, 1), + (200, 'Missing', NULL, 'Missing man', 'Anton', 'The space', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 4, NULL, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1), + (400, 'Trash', NULL, 'Garbage man', 'Unknown name', 'New York city', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 4, NULL, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1); + +INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `phone`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`) + SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), CONCAT(name, 'Social'), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'SILLA', 46460, 623111111, 1, CONCAT(name,'@verdnatura.es'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, CURDATE(), 1 + FROM `account`.`role` `r` + WHERE `r`.`hasLogin` = 1; INSERT INTO `vn`.`clientManaCache`(`clientFk`, `mana`, `dated`) VALUES @@ -258,6 +263,11 @@ INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `pr (131, 'Missing', 'The space', 'Silla', 46460, 1, 1111111111, 222222222, 1, 200, 2, NULL, NULL, 0, 0), (132, 'Trash', 'New York city', 'Silla', 46460, 1, 1111111111, 222222222, 1, 400, 2, NULL, NULL, 0, 0); +INSERT INTO `vn`.`address`( `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `isActive`, `clientFk`, `agencyModeFk`, `isDefaultAddress`) + SELECT name, CONCAT(name, 'Street'), 'SILLA', 46460, 1, 1, id, 2, 1 + FROM `account`.`role` `r` + WHERE `r`.`hasLogin` = 1; + UPDATE `vn`.`client` SET defaultAddressFk = 1 WHERE id = 101; UPDATE `vn`.`client` SET defaultAddressFk = 2 WHERE id = 102; UPDATE `vn`.`client` SET defaultAddressFk = 3 WHERE id = 103; @@ -271,6 +281,11 @@ UPDATE `vn`.`client` SET defaultAddressFk = 10 WHERE id = 110; UPDATE `vn`.`client` SET defaultAddressFk = 11 WHERE id = 200; UPDATE `vn`.`client` SET defaultAddressFk = 12 WHERE id = 400; +UPDATE `vn`.`client` `c` + JOIN `vn`.`address` `a` ON `a`.`clientFk` = `c`.`id` + SET `c`.`defaultAddressFk` = `a`.`id` + WHERE `defaultAddressFk` IS NULL; + INSERT INTO `vn`.`clientCredit`(`id`, `clientFk`, `workerFk`, `amount`, `created`) VALUES (1 , 101, 5, 300, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), diff --git a/modules/client/back/methods/client/isValidClient.js b/modules/client/back/methods/client/isValidClient.js index 583efa299..241121927 100644 --- a/modules/client/back/methods/client/isValidClient.js +++ b/modules/client/back/methods/client/isValidClient.js @@ -29,22 +29,23 @@ module.exports = Self => { } }); - Self.isValidClient = async function(id) { + Self.isValidClient = async id => { let query = `SELECT r.name - FROM salix.Account A - JOIN vn.client C ON A.id = C.id - JOIN salix.RoleMapping rm ON rm.principalId = A.id + FROM salix.Account a + JOIN vn.client c ON a.id = c.id + JOIN salix.RoleMapping rm ON rm.principalId = a.id JOIN salix.Role r ON r.id = rm.roleId - WHERE A.id = ? AND C.isActive AND C.isTaxDataChecked`; + WHERE a.id = ? AND c.isActive AND c.isTaxDataChecked`; let roleNames = await Self.rawSql(query, [id]); - if (!roleNames.length) return false; - roleNames.forEach(role => { - if (role.name === 'employee') - return false; + let isEmployee = roleNames.findIndex(role => { + return role.name === 'employee'; }); + + if (!roleNames.length || isEmployee > -1 ) return false; + return true; }; }; diff --git a/modules/client/back/methods/client/specs/isValidClient.spec.js b/modules/client/back/methods/client/specs/isValidClient.spec.js index f995bb7ab..446392374 100644 --- a/modules/client/back/methods/client/specs/isValidClient.spec.js +++ b/modules/client/back/methods/client/specs/isValidClient.spec.js @@ -1,57 +1,45 @@ const app = require('vn-loopback/server/server'); describe('Client isValidClient', () => { - it('should call the isValidClient() method with a client id and receive true', done => { + it('should call the isValidClient() method with a client id and receive true', async() => { let id = 101; - app.models.Client.isValidClient(id) - .then(result => { - expect(result).toBeTruthy(); - done(); - }); + let result = await app.models.Client.isValidClient(id); + + expect(result).toBeTruthy(); }); - it('should call the isValidClient() method with a employee id and receive false', done => { + it('should call the isValidClient() method with an employee id to receive false', async() => { let id = 1; - app.models.Client.isValidClient(id) - .then(result => { - expect(result).toBeFalsy(); - done(); - }); + let result = await app.models.Client.isValidClient(id); + + expect(result).toBeFalsy(); }); - it('should call the isValidClient() method with a unexistant id and receive false', done => { + it('should call the isValidClient() method with an unexistant id and receive false', async() => { let id = 999999; - app.models.Client.isValidClient(id) - .then(result => { - expect(result).toBeFalsy(); - done(); - }); + let result = await app.models.Client.isValidClient(id); + + expect(result).toBeFalsy(); }); - it('should call the isValidClient() method with a invalid id and receive false', done => { + it('should call the isValidClient() method with an invalid id and receive false', async() => { let id = 'Pepinillos'; - app.models.Client.isValidClient(id) - .then(result => { - expect(result).toBeFalsy(); - done(); - }); + let result = await app.models.Client.isValidClient(id); + + expect(result).toBeFalsy(); }); - it('should call the isValidClient() method with a customer id which isnt active and return false', done => { + it('should call the isValidClient() method with a customer id which isnt active and return false', async() => { let id = '106'; - app.models.Client.isValidClient(id) - .then(result => { - expect(result).toBeFalsy(); - done(); - }); + let result = await app.models.Client.isValidClient(id); + + expect(result).toBeFalsy(); }); - it('should call the isValidClient() method with a customer id which his data isnt verified and return false', done => { + it('should call the isValidClient() method with a customer id which his data isnt verified and return false', async() => { let id = '110'; - app.models.Client.isValidClient(id) - .then(result => { - expect(result).toBeFalsy(); - done(); - }); + let result = await app.models.Client.isValidClient(id); + + expect(result).toBeFalsy(); }); });