SkateSpots/src/lib/newsletterIssues.test.ts
SkateSpots bcd99994a9 test: cover zap helpers and newsletter data
- useZapTotals: zapTargetKey (regular id vs addressable coord) and
  zapReceiptSats (amount tag -> bolt11 -> description JSON -> 0, malformed safe)
- newsletterIssues: schema, newest-first ordering, publish hashtags
2026-09-26 19:45:48 +07:00

36 lines
1.4 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { NEWSLETTER_ISSUES } from './newsletterIssues';
describe('NEWSLETTER_ISSUES data', () => {
it('has at least one issue', () => {
expect(NEWSLETTER_ISSUES.length).toBeGreaterThan(0);
});
it('every issue satisfies the schema', () => {
for (const issue of NEWSLETTER_ISSUES) {
expect(typeof issue.number).toBe('number');
expect(issue.date).toMatch(/^\d{4}-\d{2}-\d{2}$/);
expect(issue.vibe.trim().length).toBeGreaterThan(0);
expect(issue.communityNote.trim().length).toBeGreaterThan(0);
expect(issue.nostrText.trim().length).toBeGreaterThan(0);
expect(Array.isArray(issue.updates)).toBe(true);
expect(issue.updates.length).toBeGreaterThan(0);
for (const u of issue.updates) {
expect(u.title.trim().length).toBeGreaterThan(0);
expect(u.body.trim().length).toBeGreaterThan(0);
expect(u.tag.trim().length).toBeGreaterThan(0);
}
}
});
it('is ordered newest-first (descending issue numbers)', () => {
for (let i = 1; i < NEWSLETTER_ISSUES.length; i++) {
expect(NEWSLETTER_ISSUES[i - 1].number).toBeGreaterThan(NEWSLETTER_ISSUES[i].number);
}
});
it('includes the d-tagged hashtags used to publish issues', () => {
const withNewsTag = NEWSLETTER_ISSUES.filter((i) => i.nostrText.includes('#skatespotsnews'));
expect(withNewsTag.length).toBeGreaterThan(0);
});
});