✨ feature: Implement Gmail message fetching and Excel sheet name truncation
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user