18 lines
1.1 KiB
TypeScript
18 lines
1.1 KiB
TypeScript
import { test } from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { convertImapMessage } from '../src/main/lib/imap-message.ts'
|
|
|
|
test('общий преобразователь сохраняет UID, прочитанность и вложения', (): void => {
|
|
const converted = convertImapMessage({ uid: 12, envelope: { from: [{ name: 'Автор', address: 'user@example.org' }], subject: 'Тема', messageId: '<message@example.org>' }, flags: new Set<string>(['\\Seen']), bodyStructure: { childNodes: [{ disposition: 'attachment' }] }, internalDate: new Date('2026-11-17T12:00:00Z') }, 'INBOX')
|
|
assert.equal(converted.id, '12')
|
|
assert.equal(converted.flags.seen, true)
|
|
assert.equal(converted.hasAttachments, true)
|
|
assert.equal(converted.date, '2026-11-17T12:00:00.000Z')
|
|
})
|
|
|
|
test('письмо без Date не меняет идентичность при повторном чтении', (): void => {
|
|
const first = convertImapMessage({ uid: 1 }, 'INBOX')
|
|
const second = convertImapMessage({ uid: 1 }, 'INBOX')
|
|
assert.equal(first.date, second.date)
|
|
assert.equal(first.date, '1970-01-01T00:00:00.000Z')
|
|
})
|