import { describe, it, expect, vi } from 'vitest' import DOMPurify from 'dompurify' import { ref } from 'vue' import { useI18n } from '@/composables/useI18n' describe('useI18n composable', () => { describe('t() function with plain language string', () => { it('should return Finnish translation', () => { const { t } = useI18n('fi') const result = t('noWarnings') expect(result).toBeTruthy() expect(typeof result).toBe('string') }) it('should return English translation', () => { const { t } = useI18n('en') const result = t('noWarnings') expect(result).toBeTruthy() expect(typeof result).toBe('string') }) it('should return Swedish translation', () => { const { t } = useI18n('sv') const result = t('noWarnings') expect(result).toBeTruthy() expect(typeof result).toBe('string') }) it('should return empty string for unknown language', () => { const { t } = useI18n('de') const result = t('noWarnings') expect(result).toBe('') }) it('should return empty string for null key', () => { const { t } = useI18n('fi') const result = t(null) expect(result).toBe('') }) it('should return empty string for undefined key', () => { const { t } = useI18n('fi') const result = t(undefined) expect(result).toBe('') }) it('should return empty string for non-existent key', () => { const { t } = useI18n('fi') const result = t('nonExistentKey12345') expect(result).toBe('') }) it('should sanitize HTML in translations', () => { const { t } = useI18n('fi') // Assuming translations don't contain scripts const result = t('noWarnings') expect(result).not.toContain('