Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
test(windows): verify synthetic IBAN length and mod-97 validity
davoodmehraban89 committed
Oct 17, 2026 at 02:04 UTC
3cda5b393f97f4e58ba5472a236d5751a67d3864
1 file changed
+25
qa/windows/synthetic-iban.node.mjs
new
+25
@@ -0,0 +1,25 @@
1
+import test from 'node:test';
2
+import assert from 'node:assert/strict';
3
+import { createSyntheticIranianIban } from './synthetic-iban.mjs';
4
+
5
+function mod97(iban) {
6
+ const rearranged = iban.slice(4) + iban.slice(0, 4);
7
+ let remainder = 0;
8
+ for (const ch of rearranged) {
9
+ const sequence = /[0-9]/.test(ch) ? ch : String(ch.charCodeAt(0) - 55);
10
+ for (const digit of sequence) remainder = (remainder * 10 + Number(digit)) % 97;
11
+ }
12
+ return remainder;
13
+}
14
+test('VM-only source and beneficiary IBANs are exactly 26 characters and checksum-valid', () => {
15
+ for (const seed of [1, 2]) {
16
+ const iban = createSyntheticIranianIban(seed);
17
+ assert.match(iban, /^IR[0-9]{24}$/);
18
+ assert.equal(iban.length, 26);
19
+ assert.equal(mod97(iban), 1);
20
+ }
21
+ assert.notEqual(createSyntheticIranianIban(1), createSyntheticIranianIban(2));
22
+});
23
+test('rejects fixture seeds outside the synthetic one-digit range', () => {
24
+ for (const value of [0, 10, -1, 1.1, NaN]) assert.throws(() => createSyntheticIranianIban(value));
25
+});