test(supplier): add backTest to check changes in isPayMethodChecked
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2021-12-20 08:02:28 +01:00
parent 9247bc98f1
commit 7a0221c17d
1 changed files with 27 additions and 1 deletions

View File

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