21 lines
551 B
TypeScript
21 lines
551 B
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { slugify } from '$lib/slugify';
|
|
|
|
describe('slugify', () => {
|
|
it('converts to lowercase with hyphens', () => {
|
|
expect(slugify('Hello World')).toBe('hello-world');
|
|
});
|
|
|
|
it('removes special characters', () => {
|
|
expect(slugify("Buddy's Adventure!")).toBe('buddys-adventure');
|
|
});
|
|
|
|
it('collapses multiple hyphens', () => {
|
|
expect(slugify('foo bar---baz')).toBe('foo-bar-baz');
|
|
});
|
|
|
|
it('trims leading and trailing hyphens', () => {
|
|
expect(slugify(' hello ')).toBe('hello');
|
|
});
|
|
});
|