Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { EVENT_SLUG_FALLBACK, shouldAutogenerateEventSlug, slugifyEventTitle } from '@/features/events/eventSlug'
|
|
|
|
describe('slugifyEventTitle', () => {
|
|
it('transliterates a Persian workshop title', () => {
|
|
expect(slugifyEventTitle('کارگاه سفال تهران')).toBe('kargah-sfal-thran')
|
|
})
|
|
|
|
it('slugifies an already-Latin title', () => {
|
|
expect(slugifyEventTitle('Pottery Workshop Tehran')).toBe('pottery-workshop-tehran')
|
|
})
|
|
|
|
it('returns empty for a blank title so the wizard can wait', () => {
|
|
expect(slugifyEventTitle(' ')).toBe('')
|
|
})
|
|
|
|
it('falls back when the title has no latinizable characters', () => {
|
|
expect(slugifyEventTitle('🙂🙂')).toBe(EVENT_SLUG_FALLBACK)
|
|
})
|
|
|
|
it('does not use the reserved application slug', () => {
|
|
expect(slugifyEventTitle('new')).toBe(EVENT_SLUG_FALLBACK)
|
|
})
|
|
})
|
|
|
|
describe('shouldAutogenerateEventSlug', () => {
|
|
it('follows the title when the slug is empty or still generated from it', () => {
|
|
expect(shouldAutogenerateEventSlug('', 'کارگاه سفال')).toBe(true)
|
|
expect(shouldAutogenerateEventSlug('kargah-sfal', 'کارگاه سفال')).toBe(true)
|
|
})
|
|
|
|
it('replaces the old random event-xxxxxxxx placeholder', () => {
|
|
expect(shouldAutogenerateEventSlug('event-a3f1c9e2', 'کارگاه سفال')).toBe(true)
|
|
})
|
|
|
|
it('stops following after a manual slug edit', () => {
|
|
expect(shouldAutogenerateEventSlug('custom-slug', 'کارگاه سفال')).toBe(false)
|
|
})
|
|
})
|