32 lines
1.7 KiB
TypeScript
32 lines
1.7 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
|
import { resolve } from 'node:path';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { validateEventCollection } from '../src/data/event-schema';
|
|
import { parseEventSource } from '../src/data/event-parser';
|
|
import { getStaticRoutes } from '../src/router/routes';
|
|
import { absoluteUrl } from '../src/config/site';
|
|
|
|
const festasSource = readFileSync(resolve(process.cwd(), 'content/events/festas-2026.md'), 'utf8');
|
|
|
|
describe('event content', () => {
|
|
it('parses the initial event, preserving its share text and Markdown body', () => {
|
|
const event = parseEventSource(festasSource, 'festas-2026.md');
|
|
|
|
expect(event.facebook.url).toBe('https://www.facebook.com/story.php?story_fbid=122327514458210862&id=61556325866671');
|
|
expect(event.share.text).toBe('Já está tudo preparado para mais um grande fim de semana na Rebolaria! 🎉🥳\n\nDias 5, 6 e 7 de setembro, apareçam e venham festejar connosco! ❤️💚\n\nVejam o programa completo aqui em baixo 👇');
|
|
expect(event.html).toContain('<h2>Sobre o evento</h2>');
|
|
});
|
|
|
|
it('rejects duplicate slugs and more than one active event', () => {
|
|
const event = parseEventSource(festasSource);
|
|
expect(() => validateEventCollection([event, { ...event, active: false }])).toThrow('Duplicate event slug');
|
|
expect(() => validateEventCollection([event, { ...event, slug: 'outro-evento' }])).toThrow('Only one event');
|
|
});
|
|
|
|
it('generates a static page for the active and historical event URL', () => {
|
|
expect(getStaticRoutes()).toContain('/partilhar/festas-2026');
|
|
expect(getStaticRoutes()).toContain('/partilhar');
|
|
expect(absoluteUrl('/images/events/festas-2026.png')).toBe('https://crr.jcarreira.pt/images/events/festas-2026.png');
|
|
});
|
|
});
|