From 7a0221c17d510e23d7c4f75e8a01fc1ff50dc08a Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 20 Dec 2021 08:02:28 +0100 Subject: [PATCH] test(supplier): add backTest to check changes in isPayMethodChecked --- .../back/models/specs/supplier.spec.js | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/modules/supplier/back/models/specs/supplier.spec.js b/modules/supplier/back/models/specs/supplier.spec.js index 8721e826c..3140981c3 100644 --- a/modules/supplier/back/models/specs/supplier.spec.js +++ b/modules/supplier/back/models/specs/supplier.spec.js @@ -55,13 +55,39 @@ describe('loopback model Supplier', () => { expect(error).not.toBeDefined(); }); - it('should have unchecked isPayMethodChecked', async() => { + it('should have checked isPayMethodChecked for payMethod hasVerfified is false', async() => { const supplier = await models.Supplier.findById(442); + await supplier.updateAttribute('isPayMethodChecked', true); await supplier.updateAttribute('payMethodFk', 5); const result = await models.Supplier.findById(442); + expect(result.isPayMethodChecked).toEqual(true); + }); + + it('should have unchecked isPayMethodChecked for payMethod hasVerfified is true', async() => { + const supplier = await models.Supplier.findById(442); + await supplier.updateAttribute('isPayMethodChecked', true); + await supplier.updateAttribute('payMethodFk', 2); + + const result = await models.Supplier.findById(442); + expect(result.isPayMethodChecked).toEqual(false); }); + + it('should have unchecked isPayMethodChecked for payDay and peyDemFk', async() => { + const supplier = await models.Supplier.findById(442); + + await supplier.updateAttribute('isPayMethodChecked', true); + await supplier.updateAttribute('payDay', 5); + const firstResult = await models.Supplier.findById(442); + + await supplier.updateAttribute('isPayMethodChecked', true); + await supplier.updateAttribute('payDemFk', 1); + const secondResult = await models.Supplier.findById(442); + + expect(firstResult.isPayMethodChecked).toEqual(false); + expect(secondResult.isPayMethodChecked).toEqual(false); + }); }); });