Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
99 lines
2.7 KiB
Swift
99 lines
2.7 KiB
Swift
//
|
|
// 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"
|
|
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",
|
|
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",
|
|
"--xc-strings",
|
|
"true",
|
|
"--static-members",
|
|
"true"
|
|
]
|
|
|
|
XCTAssertEqual(arguments, expectedArguments)
|
|
}
|
|
}
|