Files
resgen.swift/Tests/ResgenSwiftTests/Generate/ColorsConfigurationTests.swift
Thibaut Schmitt f329386ccf
All checks were successful
gitea-openium/resgen.swift/pipeline/head This commit looks good
feat(RES-58): Add new parameter "bundle" (#19)
Add bundle parameter to define if resource should be load from Bundle.main (app) or Bundle.module (SPM package)

Reviewed-on: #19
2025-07-25 16:14:36 +02:00

98 lines
2.7 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,
assetBundle: 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",
assetBundle: "module",
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",
"--asset-bundle",
"module",
"--static-members",
"false"
]
XCTAssertEqual(arguments, expectedArguments)
}
}