//
//  StringsConfigurationTests.swift
//  ResgenSwift
//
//  Created by Thibaut Schmitt on 18/07/2025.
//

import Foundation
@testable import ResgenSwift
import XCTest

final class StringsConfigurationTests: XCTestCase {

    let projectDirectory = "projectDirectory/"
    
    func test_argsGeneration_requiredArgs() {
        // Given
        let testingConfiguration = StringsConfiguration(
            inputFile: "path/to/strings.txt",
            outputPath: "Strings/Generated",
            langs: "fr en en-us",
            defaultLang: "en",
            extensionOutputPath: nil, // Strings/Generated
            extensionName: nil, // String
            extensionSuffix: nil, // Testing
            visibility: nil, // "internal"
            assetBundle: nil, // .main
            staticMembers: nil, // true
            xcStrings: nil // true
        )

        // When
        let arguments = testingConfiguration.getArguments(
            projectDirectory: projectDirectory,
            force: false
        )
                
        // Expect
        let expectedArguments = [
            "projectDirectory/path/to/strings.txt",
            "--output-path",
            "projectDirectory/Strings/Generated",
            "--langs",
            "fr en en-us",
            "--default-lang",
            "en"
        ]

        XCTAssertEqual(arguments, expectedArguments)
    }
    
    func test_argsGeneration_allArguments() {
        // Given
        let testingConfiguration = StringsConfiguration(
            inputFile: "path/to/strings.txt",
            outputPath: "Strings/Generated",
            langs: "fr en en-us",
            defaultLang: "en",
            extensionOutputPath: "Strings/Generated",
            extensionName: "AppString",
            extensionSuffix: "Testing",
            visibility: "internal",
            assetBundle: "module",
            staticMembers: true,
            xcStrings: true
        )

        // When
        let arguments = testingConfiguration.getArguments(
            projectDirectory: projectDirectory,
            force: true
        )

        // Expect
        let expectedArguments = [
            "-f",
            "projectDirectory/path/to/strings.txt",
            "--output-path",
            "projectDirectory/Strings/Generated",
            "--langs",
            "fr en en-us",
            "--default-lang",
            "en",
            "--extension-output-path",
            "projectDirectory/Strings/Generated",
            "--extension-name",
            "AppString",
            "--extension-suffix",
            "Testing",
            "--visibility",
            "internal",
            "--asset-bundle",
            "module",
            "--xc-strings",
            "true",
            "--static-members",
            "true"
        ]

        XCTAssertEqual(arguments, expectedArguments)
    }
}
