add bounded ICS calendar import
This commit is contained in:
+16
-1
@@ -1,6 +1,6 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createTenderICS, tenderDeadline, deadlineInfo, calendarMonthDays, istanbulDateKey } from '../src/services/tenderCalendar.js';
|
||||
import { createTenderICS, parseTenderICS, tenderDeadline, deadlineInfo, calendarMonthDays, istanbulDateKey } from '../src/services/tenderCalendar.js';
|
||||
const t = {ikn:'2026/1582991',baslik:'Mikroskop',kurum:'Giresun',tarih:'10.09.2026',saat:'',aciklama:'Tarih ve Saati : 10.09.2026 - 10:00'};
|
||||
test('Giresun date is September 10 at 10:00 Turkey, not hard-coded August', () => {
|
||||
assert.equal(tenderDeadline(t).toISOString(),'2026-09-10T07:00:00.000Z');
|
||||
@@ -96,3 +96,18 @@ test('calendar month navigation crosses year boundaries without invalid months',
|
||||
assert.equal(shiftCalendarMonth('0001-01',-1),null);
|
||||
assert.equal(shiftCalendarMonth('2026-13',1),null);
|
||||
});
|
||||
|
||||
test('ICS import preserves Istanbul deadline, source identity and escaped text', () => {
|
||||
const ics=createTenderICS({ikn:'2026/42',baslik:'Mikroskop',kurum:'Giresun Hastanesi',tarih:'10.09.2026',saat:'10:00'});
|
||||
const imported=parseTenderICS(ics);
|
||||
assert.equal(imported.length,1);
|
||||
assert.deepEqual(imported[0],{id:imported[0].id,ikn:'2026/42',baslik:'Mikroskop',kurum:'Giresun Hastanesi',sehir:'',tarih:'10.09.2026',saat:'10:00',durum:'Harici takvim',alimTuru:'',externalCalendar:true,icsSequence:0});
|
||||
});
|
||||
|
||||
test('ICS import rejects malformed, oversized and unbounded event collections', () => {
|
||||
assert.throws(() => parseTenderICS('BEGIN:VCALENDAR\nEND:VCALENDAR'), /etkinliği bulunamadı/);
|
||||
assert.throws(() => parseTenderICS('x'.repeat(200001)), /çok büyük/);
|
||||
const many=Array.from({length:101},(_,i)=>`BEGIN:VEVENT\nUID:${i}\nDTSTART:20260910T100000Z\nSUMMARY:E${i}\nEND:VEVENT`).join('\n');
|
||||
assert.throws(() => parseTenderICS(many), /en fazla 100/);
|
||||
assert.throws(() => parseTenderICS('BEGIN:VEVENT\nUID:x\nDTSTART:20260231T100000Z\nSUMMARY:Bozuk\nEND:VEVENT'), /tarih veya başlık/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user