Skip to content

Commit

Permalink
Fix the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtBIT committed May 13, 2020
1 parent 420b0b7 commit 484458d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/ips.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ describe('IPS data string generator', () => {
c: 1,
v: '01',
k: 'PR',
r: '160000000001006645',
r: '123456789012345611',
i: 'RSD1295,',
n: 'JEST Ltd., Test',
rs: 'test-2020',
sf: '123',
s: 'Testing'
};
const result = 'K:PR|V:01|C:1|R:160000000001006645|I:RSD1295,|N:JEST Ltd., Test|RS:test-2020|SF:123|S:Testing';
const result = 'K:PR|V:01|C:1|R:123456789012345611|I:RSD1295,|N:JEST Ltd., Test|RS:test-2020|SF:123|S:Testing';
await expect(generateIpsDataString(args)).resolves.toBe(result);
});
});
6 changes: 6 additions & 0 deletions lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ module.exports = yup.object({
r: yup.string()
.matches(/^[0-9]{18}$/, "Must contain exactly 18 numeric characters")
.test('bank-account', "Value is not a valid bank account", value => {
if (!value) {
return false;
}
const account = parseInt(value.substr(0, 16));
const control = parseInt(value.substr(16));
return control === 98 - (account * 100) % 97;
Expand All @@ -21,6 +24,9 @@ module.exports = yup.object({
o: yup.string()
.matches(/^[0-9]{18}$/, "Must contain exactly 18 numeric characters")
.test('bank-account', "Value is not a valid bank account", value => {
if (!value) {
return true;
}
const account = parseInt(value.substr(0, 16));
const control = parseInt(value.substr(16));
return control === 98 - (account * 100) % 97;
Expand Down

0 comments on commit 484458d

Please sign in to comment.