Refractoring Stage 2 Add Refractor plan.md
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { makeCalendarData, makeVcard } = require('../desktop/dav-codecs.cjs');
|
||||
|
||||
test('serializes calendar events with escaped values and stable injected identifiers', () => {
|
||||
const data = makeCalendarData({
|
||||
date: '2026-10-16',
|
||||
title: 'Review, plan; follow-up',
|
||||
place: 'Room A, west',
|
||||
notes: 'First line\nSecond line',
|
||||
_dav: { uid: 'event-1' }
|
||||
}, { now: () => new Date('2026-10-16T12:34:56.000Z') });
|
||||
|
||||
assert.match(data, /UID:event-1\r\n/);
|
||||
assert.match(data, /DTSTAMP:20261016T123456Z\r\n/);
|
||||
assert.match(data, /DTSTART;VALUE=DATE:20261016\r\n/);
|
||||
assert.match(data, /SUMMARY:Review\\, plan\\; follow-up\r\n/);
|
||||
assert.match(data, /LOCATION:Room A\\, west\r\n/);
|
||||
assert.match(data, /DESCRIPTION:First line\\nSecond line\r\n/);
|
||||
});
|
||||
|
||||
test('serializes contacts with escaped fields and an injected identifier', () => {
|
||||
const data = makeVcard({
|
||||
name: 'Ada Example Lovelace',
|
||||
email: 'ada@example.com',
|
||||
note: 'Research, analysis; mathematics',
|
||||
_dav: { uid: 'contact-1' }
|
||||
});
|
||||
|
||||
assert.equal(data,
|
||||
'BEGIN:VCARD\r\nVERSION:3.0\r\nUID:contact-1\r\nFN:Ada Example Lovelace\r\n' +
|
||||
'N:Example Lovelace;Ada;;;\r\nEMAIL:ada@example.com\r\n' +
|
||||
'NOTE:Research\\, analysis\\; mathematics\r\nEND:VCARD\r\n');
|
||||
});
|
||||
Reference in New Issue
Block a user