2873-create-supplier-beneficiary #593

Merged
carlosjr merged 9 commits from 2873-create-supplier-beneficiary into dev 2021-04-21 13:29:29 +00:00
3 changed files with 20 additions and 20 deletions
Showing only changes of commit cd4f93f326 - Show all commits

View File

@ -8,7 +8,9 @@ Salix is also the scientific name of a beautifull tree! :)
Required applications. Required applications.
* Node.js = 14.15.1 LTS * Node.js = 14.x LTS
* Docker
* Git
* Docker * Docker
You will need to install globally the following items. You will need to install globally the following items.

View File

@ -9,19 +9,18 @@ describe('loopback model Supplier-account', () => {
let error; let error;
const expectedError = 'The IBAN does not have the correct format'; const expectedError = 'The IBAN does not have the correct format';
const iban = 'incorrect format'; const iban = 'incorrect format';
// si falla el error es extraño preguntar a carlos try {
carlosjr marked this conversation as resolved Outdated

I would wrap this cone into a try-catch

I would wrap this cone into a try-catch
await app.models.SupplierAccount.create(
await app.models.SupplierAccount.create( {
{ supplierFk: supplierId,
supplierFk: supplierId, bankEntityFk: bankEntityId,
bankEntityFk: bankEntityId, iban: iban
iban: iban });
} } catch (e) {
).catch(e => {
error = e; error = e;
expect(error.message).toContain(expectedError); expect(error.message).toContain(expectedError);
}); }
expect(error).toBeDefined(); expect(error).toBeDefined();
}); });
@ -47,13 +46,12 @@ describe('loopback model Supplier-account', () => {
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx active: activeCtx
}); });
const createdSupplierAccount = await app.models.SupplierAccount.create( const createdSupplierAccount = await app.models.SupplierAccount.create({
{ supplierFk: supplierId,
supplierFk: supplierId, bankEntityFk: bankEntityId,
carlosjr marked this conversation as resolved Outdated

I would move the { to the begining of the previous line and the "," should be at the end of the previous line.

I would move the { to the begining of the previous line and the "," should be at the end of the previous line.
bankEntityFk: bankEntityId, iban: iban
iban: iban },
} options);
, options);
expect(createdSupplierAccount.iban).toBe(iban); expect(createdSupplierAccount.iban).toBe(iban);
await tx.rollback(); await tx.rollback();

View File

@ -1,11 +1,11 @@
const validateIban = require('vn-loopback/util/validateIban'); const validateIban = require('vn-loopback/util/validateIban');
module.exports = Self => { module.exports = Self => {
Self.validateAsync('iban', ibanNeedsValidation, { Self.validateAsync('iban', ibanValidation, {
message: 'The IBAN does not have the correct format' message: 'The IBAN does not have the correct format'
}); });
async function ibanNeedsValidation(err, done) { async function ibanValidation(err, done) {
carlosjr marked this conversation as resolved Outdated

since this method doesn-t return a boolean I would recommend "ibanValidation" for the name

since this method doesn-t return a boolean I would recommend "ibanValidation" for the name
let filter = { let filter = {
fields: ['code'], fields: ['code'],
where: {id: this.countryFk} where: {id: this.countryFk}