import XCTest
@testable import PortfolioJournal

final class ShareServiceTests: XCTestCase {
    func testBuildMonthlyCheckInShareText() {
        let summary = MonthlySummary(
            periodLabel: "January 2026",
            startDate: Date(timeIntervalSince1970: 0),
            endDate: Date(timeIntervalSince1970: 0),
            startingValue: 1000,
            endingValue: 1200,
            contributions: 150,
            netPerformance: 50
        )

        let text = ShareService.buildMonthlyCheckInShareText(
            summary: summary,
            appName: "Portfolio Journal"
        )

        XCTAssertTrue(text.contains("January 2026 Check-in"))
        XCTAssertTrue(text.contains("Starting:"))
        XCTAssertTrue(text.contains("Ending:"))
        XCTAssertTrue(text.contains("Contributions:"))
        XCTAssertTrue(text.contains("Net performance:"))
        XCTAssertTrue(text.contains("Shared from Portfolio Journal"))
    }

    func testBuildPortfolioValueShareText() {
        let text = ShareService.buildPortfolioValueShareText(
            totalValue: "€120,000",
            changeText: "+€2,500 (+2.1%)",
            changeLabel: "since last check-in",
            yearChange: "+€8,000 (+7.1%)",
            sinceInceptionChange: "+€24,000 (+25.0%)",
            appName: "Portfolio Journal"
        )

        XCTAssertTrue(text.contains("Total Portfolio Value"))
        XCTAssertTrue(text.contains("€120,000"))
        XCTAssertTrue(text.contains("+€2,500 (+2.1%) since last check-in"))
        XCTAssertTrue(text.contains("YoY: +€8,000 (+7.1%)"))
        XCTAssertTrue(text.contains("Since inception: +€24,000 (+25.0%)"))
        XCTAssertTrue(text.contains("Shared from Portfolio Journal"))
    }
}
