import { describe, expect, it, vi } from 'vitest'
import { renderToStaticMarkup } from 'react-dom/server'
import type { PostStatus } from '~/domain/types'

vi.mock('next-intl', () => ({
	useTranslations: () => (key: string) => key,
}))

vi.mock('~/lib/entry-actions', () => ({
	archiveEntry: vi.fn(),
	publishEntry: vi.fn(),
	resumeEntry: vi.fn(),
	unscheduleEntry: vi.fn(),
}))

const { EntryStatusControl } = await import('~/components/admin/EntryStatusControl')

function render(status: PostStatus): string {
	return renderToStaticMarkup(<EntryStatusControl id="e1f7f2f0-0000-4000-8000-000000000001" status={status} />)
}

describe('EntryStatusControl', () => {
	it('bietet zu jedem Status den passenden Schritt an', () => {
		expect(render('draft')).toContain('actions.publish')
		expect(render('scheduled')).toContain('actions.unschedule')
		expect(render('published')).toContain('actions.archive')
		expect(render('archived')).toContain('actions.resume')
	})

	it('zeigt den Status immer als Marke', () => {
		expect(render('draft')).toContain('status.draft')
		expect(render('published')).toContain('status.published')
	})
})
