Files
website/src/lib/server/slugify.test.ts
Stan Runge d0c7b6548b
Some checks failed
Test and deploy staging / staging (push) Has been cancelled
beeeeg update
2026-09-23 04:16:50 +00:00

18 lines
590 B
TypeScript

import { describe, expect, it } from 'vitest';
import { slugify, validSlug } from './slugify';
describe('content slugs', () => {
it('turns titles into readable URL segments', () => {
expect(slugify('Hello, World!')).toBe('hello-world');
expect(slugify(' A / B ')).toBe('a-b');
expect(slugify('!!!', 'list')).toBe('list');
});
it('accepts only canonical editable slugs', () => {
expect(validSlug('my-list-2026')).toBe(true);
for (const value of ['My-List', 'two words', '-leading', 'trailing-', 'double--dash', '']) {
expect(validSlug(value)).toBe(false);
}
});
});