Some checks failed
Test and deploy staging / staging (push) Has been cancelled
18 lines
590 B
TypeScript
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);
|
|
}
|
|
});
|
|
});
|