فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

test(A02): ten synthetic strict-export regressions

davoodmehraban89 committed Oct 19, 2026 at 01:17 UTC 32288f16ff3b948aca28b6679d6c1d7f9e3c81db
1 file changed +36
tests/a02-holoo-delimited-export.test.mjs
+36
@@ -247,3 +247,39 @@ test('A02: a mapping without its source table fails closed', () => {
247 delete sample.tables.cheques;
248 assert.throws(() => previewHolooDelimitedExport(sample), /CSV_MAPPING_WITHOUT_SOURCE_TABLE/);
249 });
250 +
251 +test('A02 strict 1: reject embedded NUL bytes', () => {
252 + assert.throws(() => parseStrictDelimitedRows('id,name\n1,a\0b\n'), /CSV_NUL_BYTE/);
253 +});
254 +test('A02 strict 2: reject a second BOM after header', () => {
255 + assert.throws(() => parseStrictDelimitedRows('id,name\n1,\uFEFFname\n'), /CSV_EMBEDDED_BOM/);
256 +});
257 +test('A02 strict 3: reject header control characters', () => {
258 + assert.throws(() => parseStrictDelimitedRows('id,na\u0001me\n1,a\n'), /CSV_INVALID_HEADER/);
259 +});
260 +test('A02 strict 4: reject missing source tables', () => {
261 + const sample = fixture(); sample.tables = {}; sample.mappings = {};
262 + assert.throws(() => previewHolooDelimitedExport(sample), /CSV_NO_SOURCE_TABLES/);
263 +});
264 +test('A02 strict 5: reject empty input', () => {
265 + assert.throws(() => parseStrictDelimitedRows(''), /CSV_EMPTY_SOURCE/);
266 +});
267 +test('A02 strict 6: reject duplicate trimmed headers', () => {
268 + assert.throws(() => parseStrictDelimitedRows('id, id\n1,2\n'), /CSV_INVALID_HEADER/);
269 +});
270 +test('A02 strict 7: reject unsupported pipe separator', () => {
271 + assert.throws(() => parseStrictDelimitedRows('id|name\n1|a\n', {delimiter:'|'}), /CSV_UNSUPPORTED_DELIMITER/);
272 +});
273 +test('A02 strict 8: reject malformed row widths', () => {
274 + assert.throws(() => parseStrictDelimitedRows('id,name\n1\n'), /CSV_ROW_WIDTH_MISMATCH/);
275 +});
276 +test('A02 strict 9: reject invalid amount without currency guessing', () => {
277 + const sample = fixture(); sample.tables.cheques.text = 'id,amount\nQ1,1.50\n';
278 + const report = previewHolooDelimitedExport(sample);
279 + assert.ok(report.issues.some(x => x.code === 'AMOUNT_NOT_INTEGER_RIAL'));
280 + assert.equal(report.canCommit, false);
281 +});
282 +test('A02 strict 10: reject unsupported canonical mapping key', () => {
283 + const sample = fixture(); sample.mappings.cheques.extra = 'amount';
284 + assert.throws(() => previewHolooDelimitedExport(sample), /CSV_UNSUPPORTED_CANONICAL_FIELD/);
285 +});