import { describe, it, expect } from 'vitest';
import { extractQuote } from './comment';

describe('extractQuote', () => {
	it('returns null quote and full body for plain text', () => {
		const result = extractQuote('Hello world');
		expect(result.quote).toBeNull();
		expect(result.body).toBe('Hello world');
	});

	it('extracts quote and body with double newline separator', () => {
		const result = extractQuote('> "Some quoted text"\n\nReply body');
		expect(result.quote).toBe('Some quoted text');
		expect(result.body).toBe('Reply body');
	});

	it('extracts quote and body with single newline separator', () => {
		const result = extractQuote('> "Quote"\nBody');
		expect(result.quote).toBe('Quote');
		expect(result.body).toBe('Body');
	});

	it('returns null quote when format does not match', () => {
		const result = extractQuote('> Not a quote format');
		expect(result.quote).toBeNull();
		expect(result.body).toBe('> Not a quote format');
	});

	it('handles empty string', () => {
		const result = extractQuote('');
		expect(result.quote).toBeNull();
		expect(result.body).toBe('');
	});

	it('does not match when quotes are missing', () => {
		const result = extractQuote('> just a blockquote\n\nbody');
		expect(result.quote).toBeNull();
		expect(result.body).toBe('> just a blockquote\n\nbody');
	});
});
