From 00085f2b99d61086908ee29975cd731cbcf5b2c9 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 29 Nov 2024 17:05:13 +0100 Subject: [PATCH] feat: refs #7936 add tests for invoiceIn filter --- .../methods/invoice-in/specs/filter.spec.js | 17 +++++++++++++++++ .../methods/invoice-in/specs/invoiceIn.spec.js | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js index 48310b32a..beaa608e6 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js @@ -166,4 +166,21 @@ describe('InvoiceIn filter()', () => { throw e; } }); + + it('should return the invoice in matching companyFk', async() => { + const tx = await models.InvoiceIn.beginTransaction({}); + const options = {transaction: tx}; + + try { + const company = await models.Company.findOne({}, options); + const invoicesByCompany = await models.InvoiceIn.find({where: {companyFk: company.id}}, options); + const filteredInvoices = await models.InvoiceIn.filter({args: {companyFk: company.id}}, {}, options); + + expect(filteredInvoices.length).toEqual(invoicesByCompany.length); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js index 4e2ee36d5..69038d9fd 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -fdescribe('invoiceIn', () => { +describe('invoiceIn', () => { let options; let tx; const invoiceId = 1;