Files
resgen.swift/Tests/ResgenSwiftTests/Generate/ColorsConfigurationTests.swift
Thibaut Schmitt 7162f13166
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
Add visibility parameters to control scope of generated extension
2025-07-18 11:53:46 +02:00

94 lines
2.6 KiB
Swift

//
// ColorsConfigurationTests.swift
//
//
// Created by Thibaut Schmitt on 04/11/2022.
//
import Foundation
import XCTest
@testable import ResgenSwift
final class ColorsConfigurationTests: XCTestCase {
let projectDirectory = "projectDirectory/"
func test_argsGeneration_requiredArgs() {
// Given
let testingConfiguration = ColorsConfiguration(
inputFile: "path/to/colors.txt",
style: ColorStyle.all.rawValue,
xcassetsPath: "path/to/assets.xcassets",
extensionOutputPath: nil,
extensionName: nil,
extensionNameUIKit: nil,
extensionSuffix: nil,
visibility: nil,
staticMembers: false
)
// When
let arguments = testingConfiguration.getArguments(
projectDirectory: projectDirectory,
force: false
)
// Expect
let expectedArguments = [
"projectDirectory/path/to/colors.txt",
"--style",
"all",
"--xcassets-path",
"projectDirectory/path/to/assets.xcassets",
"--static-members",
"false"
]
XCTAssertEqual(arguments, expectedArguments)
}
func test_argsGeneration_allArguments() {
// Given
let testingConfiguration = ColorsConfiguration(
inputFile: "path/to/colors.txt",
style: ColorStyle.all.rawValue,
xcassetsPath: "path/to/assets.xcassets",
extensionOutputPath: "Colors/Generated",
extensionName: "AppUIColor",
extensionNameUIKit: "AppColor",
extensionSuffix: "Testing",
visibility: "public",
staticMembers: false
)
// When
let arguments = testingConfiguration.getArguments(
projectDirectory: projectDirectory,
force: true
)
// Expect
let expectedArguments = [
"-f",
"projectDirectory/path/to/colors.txt",
"--style",
"all",
"--xcassets-path",
"projectDirectory/path/to/assets.xcassets",
"--extension-output-path",
"projectDirectory/Colors/Generated",
"--extension-name",
"AppUIColor",
"--extension-name-ui-kit",
"AppColor",
"--extension-suffix",
"Testing",
"--visibility",
"public",
"--static-members",
"false"
]
XCTAssertEqual(arguments, expectedArguments)
}
}