From 7a98613ef86b4a62f2c39ebc416833f49489fc51 Mon Sep 17 00:00:00 2001 From: joan Date: Wed, 1 Sep 2021 11:48:21 +0200 Subject: [PATCH] Updated unit tests --- .../collection/spec/newCollection.spec.js | 2 +- db/dump/fixtures.sql | 5 +++++ .../back/methods/ticket/specs/filter.spec.js | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/back/methods/collection/spec/newCollection.spec.js b/back/methods/collection/spec/newCollection.spec.js index f57716f16f..6fbf9af8ca 100644 --- a/back/methods/collection/spec/newCollection.spec.js +++ b/back/methods/collection/spec/newCollection.spec.js @@ -6,6 +6,6 @@ describe('newCollection()', () => { let response = await app.models.Collection.newCollection(ctx, 1, 1, 1); expect(response.length).toBeGreaterThan(0); - expect(response[0].ticketFk).toEqual(1); + expect(response[0].ticketFk).toEqual(2); }); }); diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 867a830df7..995fa165f3 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1064,6 +1064,11 @@ INSERT INTO `vn`.`collection`(`id`, `workerFk`, `stateFk`) (1, 1106, 5), (2, 1106, 14); +INSERT INTO `vn`.`ticketCollection`(`id`, `ticketFk`, `collectionFk`) + VALUES + (2, 2, 1), + (3, 3, 2); + INSERT INTO `vn`.`parking` (`column`, `row`, `sectorFk`, `code`, `pickingOrder`) VALUES ('100', '01', 1, '100-01', 1); diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js index 743a3ba819..01a652b737 100644 --- a/modules/ticket/back/methods/ticket/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js @@ -202,4 +202,23 @@ describe('ticket filter()', () => { throw e; } }); + + it('should return the tickets belonging to the collection id 1', async() => { + const tx = await models.Ticket.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const ctx = {req: {accessToken: {userId: 18}}, args: {collectionFk: 1}}; + const filter = {}; + const result = await models.Ticket.filter(ctx, filter, options); + + expect(result.length).toEqual(2); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); });