feature: Implement Gmail message fetching and Excel sheet name truncation

This commit is contained in:
Keith Solomon
2026-05-17 10:59:44 -05:00
parent cb568597dc
commit 379526114c
9 changed files with 289 additions and 163 deletions
+39
View File
@@ -0,0 +1,39 @@
import { mkdtemp, rm } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import XLSX from 'xlsx';
import { ExcelWriter } from '../src/output/excel.js';
let dir = '';
beforeEach(async () => {
dir = await mkdtemp(join(tmpdir(), 'nlc-excel-'));
});
afterEach(async () => {
await rm(dir, { force: true, recursive: true });
});
describe('ExcelWriter', () => {
it('truncates newsletter sheet names to the Excel 31-character limit', async () => {
const path = join(dir, 'catalog.xlsx');
const newsletter = 'A Very Long Newsletter Name That Exceeds The Excel Limit';
await new ExcelWriter(path).write({
rows: [
{
'Source Newsletter': newsletter,
Title: 'Post',
'Link URL': 'https://example.com'
}
],
sponsors: [],
deadLinks: []
});
const workbook = XLSX.readFile(path);
expect(workbook.SheetNames[0]).toBe('A Very Long Newsletter Name Tha');
expect(workbook.SheetNames[0].length).toBe(31);
});
});