test(export): cover the export filename slug

This commit is contained in:
Julien Calixte
2026-06-17 01:30:07 +02:00
parent 2173683535
commit f37122eea1

View File

@@ -0,0 +1,17 @@
import { describe, it, expect } from 'vitest'
import { exportFilename } from './usePngExport'
describe('exportFilename', () => {
it('slugifies the plan title into a .png name', () => {
expect(exportFilename('Q3 — Checkout revamp')).toBe('macroplan-q3-checkout-revamp.png')
})
it('collapses runs of punctuation/space and trims edge dashes', () => {
expect(exportFilename(' Hello, World!! ')).toBe('macroplan-hello-world.png')
})
it('falls back to a generic name when the title has no usable characters', () => {
expect(exportFilename('')).toBe('macroplan-plan.png')
expect(exportFilename('—— ··')).toBe('macroplan-plan.png')
})
})