Barazo default frontend barazo.forum
at main 86 lines 2.4 kB view raw
1/** 2 * Tests for maturity-aware SEO helpers. 3 * @see src/lib/seo.ts 4 */ 5 6import { describe, it, expect } from 'vitest' 7import { 8 getEffectiveMaturity, 9 getMaturityMeta, 10 shouldIncludeJsonLd, 11 shouldIncludeOgTags, 12} from './seo' 13 14describe('getEffectiveMaturity', () => { 15 it('returns safe when both ratings are safe', () => { 16 expect(getEffectiveMaturity('safe', 'safe')).toBe('safe') 17 }) 18 19 it('returns mature when community is safe and category is mature', () => { 20 expect(getEffectiveMaturity('safe', 'mature')).toBe('mature') 21 }) 22 23 it('returns mature when community is mature and category is safe', () => { 24 expect(getEffectiveMaturity('mature', 'safe')).toBe('mature') 25 }) 26 27 it('returns adult when community is adult and category is safe', () => { 28 expect(getEffectiveMaturity('adult', 'safe')).toBe('adult') 29 }) 30 31 it('returns adult when community is safe and category is adult', () => { 32 expect(getEffectiveMaturity('safe', 'adult')).toBe('adult') 33 }) 34 35 it('returns adult when both are adult', () => { 36 expect(getEffectiveMaturity('adult', 'adult')).toBe('adult') 37 }) 38 39 it('returns adult when community is mature and category is adult', () => { 40 expect(getEffectiveMaturity('mature', 'adult')).toBe('adult') 41 }) 42}) 43 44describe('getMaturityMeta', () => { 45 it('returns empty object for safe rating', () => { 46 expect(getMaturityMeta('safe')).toEqual({}) 47 }) 48 49 it('returns rating meta for mature', () => { 50 const meta = getMaturityMeta('mature') 51 expect(meta).toEqual({ other: { rating: 'mature' } }) 52 }) 53 54 it('returns noindex/nofollow for adult', () => { 55 const meta = getMaturityMeta('adult') 56 expect(meta).toEqual({ robots: { index: false, follow: false } }) 57 }) 58}) 59 60describe('shouldIncludeJsonLd', () => { 61 it('returns true for safe', () => { 62 expect(shouldIncludeJsonLd('safe')).toBe(true) 63 }) 64 65 it('returns true for mature', () => { 66 expect(shouldIncludeJsonLd('mature')).toBe(true) 67 }) 68 69 it('returns false for adult', () => { 70 expect(shouldIncludeJsonLd('adult')).toBe(false) 71 }) 72}) 73 74describe('shouldIncludeOgTags', () => { 75 it('returns true for safe', () => { 76 expect(shouldIncludeOgTags('safe')).toBe(true) 77 }) 78 79 it('returns true for mature', () => { 80 expect(shouldIncludeOgTags('mature')).toBe(true) 81 }) 82 83 it('returns false for adult', () => { 84 expect(shouldIncludeOgTags('adult')).toBe(false) 85 }) 86})