From 97a66754a7518238566d86d961582cb0afbef8c8 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 22 Nov 2021 08:58:54 +0100 Subject: [PATCH] feat(item and entry): add back test --- .../entry/specs/latestBuysFilter.spec.js | 12 ++++++ .../back/methods/item/specs/filter.spec.js | 40 +++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js b/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js index f386894dd..bdd302adb 100644 --- a/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js +++ b/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js @@ -136,5 +136,17 @@ describe('Buy latests buys filter()', () => { expect(results.length).toBe(1); }); + + it('should return results matching "supplierFk"', async() => { + let ctx = { + args: { + supplierFk: 1 + } + }; + + let results = await app.models.Buy.latestBuysFilter(ctx); + + expect(results.length).toBe(2); + }); }); diff --git a/modules/item/back/methods/item/specs/filter.spec.js b/modules/item/back/methods/item/specs/filter.spec.js index 7b1fac9ac..30bdcec32 100644 --- a/modules/item/back/methods/item/specs/filter.spec.js +++ b/modules/item/back/methods/item/specs/filter.spec.js @@ -79,4 +79,44 @@ describe('item filter()', () => { throw e; } }); + + it('should return 2 result filtering by buyerFk', async() => { + const tx = await models.Item.beginTransaction({}); + const options = {transaction: tx}; + + try { + const filter = {}; + const ctx = {args: {filter: filter, buyerFk: 16}}; + const result = await models.Item.filter(ctx, filter, options); + + expect(result.length).toEqual(2); + expect(result[0].id).toEqual(16); + expect(result[1].id).toEqual(71); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should return 2 result filtering by supplierFk', async() => { + const tx = await models.Item.beginTransaction({}); + const options = {transaction: tx}; + + try { + const filter = {}; + const ctx = {args: {filter: filter, supplierFk: 1}}; + const result = await models.Item.filter(ctx, filter, options); + + expect(result.length).toEqual(2); + expect(result[0].id).toEqual(1); + expect(result[1].id).toEqual(3); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); });