2873-create-supplier-beneficiary #593
|
@ -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.
|
||||||
|
|
|
@ -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
|
|||||||
|
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
carlosjr
commented
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();
|
||||||
|
|
|
@ -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
carlosjr
commented
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}
|
||||||
|
|
Loading…
Reference in New Issue
I would wrap this cone into a try-catch