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); + }); }); });