add prefilled calendar provider links
This commit is contained in:
+12
-1
@@ -1,11 +1,22 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createTenderICS, parseTenderICS, tenderDeadline, deadlineInfo, calendarMonthDays, istanbulDateKey } from '../src/services/tenderCalendar.js';
|
||||
import { createTenderICS, parseTenderICS, tenderDeadline, deadlineInfo, calendarMonthDays, istanbulDateKey, googleCalendarUrl, outlookCalendarUrl } 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');
|
||||
assert.match(createTenderICS(t), /DTSTART:20260910T070000Z/);
|
||||
});
|
||||
test('Google and Outlook calendar links preserve the Istanbul deadline', () => {
|
||||
const google = new URL(googleCalendarUrl({...t, ihaleYeri:'Giresun salonu'}));
|
||||
assert.equal(google.hostname, 'calendar.google.com');
|
||||
assert.equal(google.searchParams.get('dates'), '20260910T070000Z/20260910T070000Z');
|
||||
assert.equal(google.searchParams.get('location'), 'Giresun salonu');
|
||||
const outlook = new URL(outlookCalendarUrl(t));
|
||||
assert.equal(outlook.hostname, 'outlook.live.com');
|
||||
assert.equal(outlook.searchParams.get('startdt'), '2026-09-10T07:00:00Z');
|
||||
assert.equal(outlook.searchParams.get('enddt'), '2026-09-10T07:00:00Z');
|
||||
assert.throws(() => googleCalendarUrl({...t,saat:'' ,aciklama:''}), /saati kaynakta bulunamadı/);
|
||||
});
|
||||
test('all five tender deadlines and year rollover', () => {
|
||||
for (const [date,time,expected] of [
|
||||
['09.09.2026','10:00','2026-09-09T07:00'],['11.09.2026','10:00','2026-09-11T07:00'],
|
||||
|
||||
Reference in New Issue
Block a user