feat(RES-58): Add new parameter "bundle" (#19)
All checks were successful
gitea-openium/resgen.swift/pipeline/head This commit looks good
All checks were successful
gitea-openium/resgen.swift/pipeline/head This commit looks good
Add bundle parameter to define if resource should be load from Bundle.main (app) or Bundle.module (SPM package) Reviewed-on: #19
This commit is contained in:
@@ -233,7 +233,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
targets: [TrackerType.firebase],
|
||||
sections: [sectionOne, sectionTwo, sectionThree],
|
||||
tags: ["ios", "iosonly"],
|
||||
staticVar: false,
|
||||
isStatic: false,
|
||||
visibility: .public
|
||||
)
|
||||
|
||||
@@ -398,7 +398,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
targets: [TrackerType.matomo],
|
||||
sections: [sectionOne, sectionTwo, sectionThree],
|
||||
tags: ["ios", "iosonly"],
|
||||
staticVar: false,
|
||||
isStatic: false,
|
||||
visibility: .package
|
||||
)
|
||||
// Expect Analytics
|
||||
@@ -565,7 +565,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
targets: [TrackerType.matomo, TrackerType.firebase],
|
||||
sections: [sectionOne, sectionTwo, sectionThree],
|
||||
tags: ["ios", "iosonly"],
|
||||
staticVar: false,
|
||||
isStatic: false,
|
||||
visibility: .internal
|
||||
)
|
||||
|
||||
|
@@ -23,10 +23,11 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
||||
// When
|
||||
let extensionContent = ColorExtensionGenerator.getExtensionContent(
|
||||
colors: colors,
|
||||
staticVar: false,
|
||||
isStatic: false,
|
||||
extensionName: "GenColors",
|
||||
isSwiftUI: false,
|
||||
visibility: .public
|
||||
visibility: .public,
|
||||
assetBundle: .main
|
||||
)
|
||||
|
||||
// Expect
|
||||
@@ -39,12 +40,12 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
||||
|
||||
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
|
||||
@objc public var colorOne: UIColor {
|
||||
UIColor(named: "colorOne")!
|
||||
UIColor(named: "colorOne", in: Bundle.main, compatibleWith: nil)!
|
||||
}
|
||||
|
||||
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
||||
@objc public var colorTwo: UIColor {
|
||||
UIColor(named: "colorTwo")!
|
||||
UIColor(named: "colorTwo", in: Bundle.main, compatibleWith: nil)!
|
||||
}
|
||||
}
|
||||
"""
|
||||
@@ -52,7 +53,7 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
}
|
||||
|
||||
func test_uiKit_GeneratedExtensionContentForStaticVar() {
|
||||
func test_uiKit_GeneratedExtensionContentForIsStatic() {
|
||||
// Given
|
||||
let colors = [
|
||||
ParsedColor(name: "colorOne", light: "#FF00FF", dark: "#00FF00"),
|
||||
@@ -62,10 +63,11 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
||||
// When
|
||||
let extensionContent = ColorExtensionGenerator.getExtensionContent(
|
||||
colors: colors,
|
||||
staticVar: true,
|
||||
isStatic: true,
|
||||
extensionName: "GenColor",
|
||||
isSwiftUI: false,
|
||||
visibility: .public
|
||||
visibility: .public,
|
||||
assetBundle: .module
|
||||
)
|
||||
|
||||
// Expect
|
||||
@@ -78,12 +80,12 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
||||
|
||||
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
|
||||
public static var colorOne: UIColor {
|
||||
UIColor(named: "colorOne")!
|
||||
UIColor(named: "colorOne", in: Bundle.module, compatibleWith: nil)!
|
||||
}
|
||||
|
||||
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
||||
public static var colorTwo: UIColor {
|
||||
UIColor(named: "colorTwo")!
|
||||
UIColor(named: "colorTwo", in: Bundle.module, compatibleWith: nil)!
|
||||
}
|
||||
}
|
||||
"""
|
||||
@@ -101,10 +103,11 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
||||
// When
|
||||
let extensionContent = ColorExtensionGenerator.getExtensionContent(
|
||||
colors: colors,
|
||||
staticVar: false,
|
||||
isStatic: false,
|
||||
extensionName: "GenColors",
|
||||
isSwiftUI: true,
|
||||
visibility: .package
|
||||
visibility: .package,
|
||||
assetBundle: .main
|
||||
)
|
||||
|
||||
// Expect
|
||||
@@ -117,12 +120,12 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
||||
|
||||
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
|
||||
package var colorOne: Color {
|
||||
Color("colorOne")
|
||||
Color("colorOne", bundle: Bundle.main)
|
||||
}
|
||||
|
||||
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
||||
package var colorTwo: Color {
|
||||
Color("colorTwo")
|
||||
Color("colorTwo", bundle: Bundle.main)
|
||||
}
|
||||
}
|
||||
"""
|
||||
@@ -130,7 +133,7 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
}
|
||||
|
||||
func test_swiftUI_GeneratedExtensionContentForStaticVar() {
|
||||
func test_swiftUI_GeneratedExtensionContentForIsStatic() {
|
||||
// Given
|
||||
let colors = [
|
||||
ParsedColor(name: "colorOne", light: "#FF00FF", dark: "#00FF00"),
|
||||
@@ -140,10 +143,11 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
||||
// When
|
||||
let extensionContent = ColorExtensionGenerator.getExtensionContent(
|
||||
colors: colors,
|
||||
staticVar: true,
|
||||
isStatic: true,
|
||||
extensionName: "GenColor",
|
||||
isSwiftUI: true,
|
||||
visibility: .internal
|
||||
visibility: .internal,
|
||||
assetBundle: .module
|
||||
)
|
||||
|
||||
// Expect
|
||||
@@ -156,12 +160,12 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
||||
|
||||
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
|
||||
internal static var colorOne: Color {
|
||||
Color("colorOne")
|
||||
Color("colorOne", bundle: Bundle.module)
|
||||
}
|
||||
|
||||
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
||||
internal static var colorTwo: Color {
|
||||
Color("colorTwo")
|
||||
Color("colorTwo", bundle: Bundle.module)
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
@@ -20,14 +20,15 @@ final class ParsedColorTests: XCTestCase {
|
||||
let property = color.getColorProperty(
|
||||
isStatic: false,
|
||||
isSwiftUI: false,
|
||||
visibility: .public
|
||||
visibility: .public,
|
||||
assetBundle: .main
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = """
|
||||
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
||||
@objc public var red: UIColor {
|
||||
UIColor(named: "red")!
|
||||
UIColor(named: "red", in: Bundle.main, compatibleWith: nil)!
|
||||
}
|
||||
"""
|
||||
|
||||
@@ -42,14 +43,15 @@ final class ParsedColorTests: XCTestCase {
|
||||
let property = color.getColorProperty(
|
||||
isStatic: true,
|
||||
isSwiftUI: false,
|
||||
visibility: .private
|
||||
visibility: .private,
|
||||
assetBundle: .module
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = """
|
||||
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
||||
private static var red: UIColor {
|
||||
UIColor(named: "red")!
|
||||
UIColor(named: "red", in: Bundle.module, compatibleWith: nil)!
|
||||
}
|
||||
"""
|
||||
|
||||
@@ -64,14 +66,15 @@ final class ParsedColorTests: XCTestCase {
|
||||
let property = color.getColorProperty(
|
||||
isStatic: false,
|
||||
isSwiftUI: true,
|
||||
visibility: .package
|
||||
visibility: .package,
|
||||
assetBundle: .main
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = """
|
||||
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
||||
package var red: Color {
|
||||
Color("red")
|
||||
Color("red", bundle: Bundle.main)
|
||||
}
|
||||
"""
|
||||
|
||||
@@ -86,14 +89,15 @@ final class ParsedColorTests: XCTestCase {
|
||||
let property = color.getColorProperty(
|
||||
isStatic: true,
|
||||
isSwiftUI: true,
|
||||
visibility: .internal
|
||||
visibility: .internal,
|
||||
assetBundle: .module
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = """
|
||||
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
||||
internal static var red: Color {
|
||||
Color("red")
|
||||
Color("red", bundle: Bundle.module)
|
||||
}
|
||||
"""
|
||||
|
||||
|
@@ -23,7 +23,7 @@ final class FontExtensionGeneratorTests: XCTestCase {
|
||||
// When
|
||||
let extensionContent = FontExtensionGenerator.getExtensionContent(
|
||||
fontsNames: fontNames,
|
||||
staticVar: false,
|
||||
isStatic: false,
|
||||
extensionName: "GenFonts",
|
||||
isSwiftUI: false,
|
||||
visibility: .public
|
||||
@@ -69,7 +69,7 @@ final class FontExtensionGeneratorTests: XCTestCase {
|
||||
// When
|
||||
let extensionContent = FontExtensionGenerator.getExtensionContent(
|
||||
fontsNames: fontNames,
|
||||
staticVar: false,
|
||||
isStatic: false,
|
||||
extensionName: "GenFonts",
|
||||
isSwiftUI: true,
|
||||
visibility: .package
|
||||
|
@@ -25,6 +25,7 @@ final class ColorsConfigurationTests: XCTestCase {
|
||||
extensionNameUIKit: nil,
|
||||
extensionSuffix: nil,
|
||||
visibility: nil,
|
||||
assetBundle: nil,
|
||||
staticMembers: false
|
||||
)
|
||||
// When
|
||||
@@ -58,6 +59,7 @@ final class ColorsConfigurationTests: XCTestCase {
|
||||
extensionNameUIKit: "AppColor",
|
||||
extensionSuffix: "Testing",
|
||||
visibility: "public",
|
||||
assetBundle: "module",
|
||||
staticMembers: false
|
||||
)
|
||||
// When
|
||||
@@ -84,6 +86,8 @@ final class ColorsConfigurationTests: XCTestCase {
|
||||
"Testing",
|
||||
"--visibility",
|
||||
"public",
|
||||
"--asset-bundle",
|
||||
"module",
|
||||
"--static-members",
|
||||
"false"
|
||||
]
|
||||
|
@@ -24,6 +24,7 @@ final class ImagesConfigurationTests: XCTestCase {
|
||||
extensionNameUIKit: nil,
|
||||
extensionSuffix: nil,
|
||||
visibility: nil,
|
||||
assetBundle: nil,
|
||||
staticMembers: nil
|
||||
)
|
||||
|
||||
@@ -53,6 +54,7 @@ final class ImagesConfigurationTests: XCTestCase {
|
||||
extensionNameUIKit: "AppImage",
|
||||
extensionSuffix: "Testing",
|
||||
visibility: "private",
|
||||
assetBundle: "module",
|
||||
staticMembers: true
|
||||
)
|
||||
|
||||
@@ -78,6 +80,8 @@ final class ImagesConfigurationTests: XCTestCase {
|
||||
"Testing",
|
||||
"--visibility",
|
||||
"private",
|
||||
"--asset-bundle",
|
||||
"module",
|
||||
"--static-members",
|
||||
"true"
|
||||
]
|
||||
|
@@ -24,6 +24,7 @@ final class StringsConfigurationTests: XCTestCase {
|
||||
extensionName: nil, // String
|
||||
extensionSuffix: nil, // Testing
|
||||
visibility: nil, // "internal"
|
||||
assetBundle: nil, // .main
|
||||
staticMembers: nil, // true
|
||||
xcStrings: nil // true
|
||||
)
|
||||
@@ -59,6 +60,7 @@ final class StringsConfigurationTests: XCTestCase {
|
||||
extensionName: "AppString",
|
||||
extensionSuffix: "Testing",
|
||||
visibility: "internal",
|
||||
assetBundle: "module",
|
||||
staticMembers: true,
|
||||
xcStrings: true
|
||||
)
|
||||
@@ -87,6 +89,8 @@ final class StringsConfigurationTests: XCTestCase {
|
||||
"Testing",
|
||||
"--visibility",
|
||||
"internal",
|
||||
"--asset-bundle",
|
||||
"module",
|
||||
"--xc-strings",
|
||||
"true",
|
||||
"--static-members",
|
||||
|
@@ -23,11 +23,12 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
||||
// When
|
||||
let extensionContent = ImageExtensionGenerator.getExtensionContent(
|
||||
images: images,
|
||||
staticVar: false,
|
||||
isStatic: false,
|
||||
extensionName: "GenImages",
|
||||
inputFilename: "myInputFilename",
|
||||
isSwiftUI: false,
|
||||
visibility: .public
|
||||
visibility: .public,
|
||||
assetBundle: .main
|
||||
)
|
||||
|
||||
// Expect
|
||||
@@ -40,11 +41,11 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
||||
extension GenImages {
|
||||
|
||||
public var image_one: UIImage {
|
||||
UIImage(named: "image_one")!
|
||||
UIImage(named: "image_one", in: Bundle.main, with: nil)!
|
||||
}
|
||||
|
||||
public var image_two: UIImage {
|
||||
UIImage(named: "image_two")!
|
||||
UIImage(named: "image_two", in: Bundle.main, with: nil)!
|
||||
}
|
||||
}
|
||||
"""
|
||||
@@ -52,7 +53,7 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
}
|
||||
|
||||
func test_uiKit_GeneratedExtensionContentForStaticVar() {
|
||||
func test_uiKit_GeneratedExtensionContentForIsStatic() {
|
||||
// Given
|
||||
let images = [
|
||||
ParsedImage(name: "image_one", tags: "id", width: 10, height: 10),
|
||||
@@ -62,11 +63,12 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
||||
// When
|
||||
let extensionContent = ImageExtensionGenerator.getExtensionContent(
|
||||
images: images,
|
||||
staticVar: true,
|
||||
isStatic: true,
|
||||
extensionName: "GenImages",
|
||||
inputFilename: "myInputFilename",
|
||||
isSwiftUI: false,
|
||||
visibility: .internal
|
||||
visibility: .internal,
|
||||
assetBundle: .module
|
||||
)
|
||||
|
||||
// Expect
|
||||
@@ -79,11 +81,11 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
||||
extension GenImages {
|
||||
|
||||
internal static var image_one: UIImage {
|
||||
UIImage(named: "image_one")!
|
||||
UIImage(named: "image_one", in: Bundle.module, with: nil)!
|
||||
}
|
||||
|
||||
internal static var image_two: UIImage {
|
||||
UIImage(named: "image_two")!
|
||||
UIImage(named: "image_two", in: Bundle.module, with: nil)!
|
||||
}
|
||||
}
|
||||
"""
|
||||
@@ -101,11 +103,12 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
||||
// When
|
||||
let extensionContent = ImageExtensionGenerator.getExtensionContent(
|
||||
images: images,
|
||||
staticVar: false,
|
||||
isStatic: false,
|
||||
extensionName: "GenImages",
|
||||
inputFilename: "myInputFilename",
|
||||
isSwiftUI: true,
|
||||
visibility: .public
|
||||
visibility: .public,
|
||||
assetBundle: .main
|
||||
)
|
||||
|
||||
// Expect
|
||||
@@ -118,11 +121,11 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
||||
extension GenImages {
|
||||
|
||||
public var image_one: Image {
|
||||
Image("image_one")
|
||||
Image("image_one", bundle: Bundle.main)
|
||||
}
|
||||
|
||||
public var image_two: Image {
|
||||
Image("image_two")
|
||||
Image("image_two", bundle: Bundle.main)
|
||||
}
|
||||
}
|
||||
"""
|
||||
@@ -130,7 +133,7 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
}
|
||||
|
||||
func test_swiftUI_GeneratedExtensionContentForStaticVar() {
|
||||
func test_swiftUI_GeneratedExtensionContentForIsStatic() {
|
||||
// Given
|
||||
let images = [
|
||||
ParsedImage(name: "image_one", tags: "id", width: 10, height: 10),
|
||||
@@ -140,11 +143,12 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
||||
// When
|
||||
let extensionContent = ImageExtensionGenerator.getExtensionContent(
|
||||
images: images,
|
||||
staticVar: true,
|
||||
isStatic: true,
|
||||
extensionName: "GenImages",
|
||||
inputFilename: "myInputFilename",
|
||||
isSwiftUI: true,
|
||||
visibility: .package
|
||||
visibility: .package,
|
||||
assetBundle: .module
|
||||
)
|
||||
|
||||
// Expect
|
||||
@@ -157,11 +161,11 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
||||
extension GenImages {
|
||||
|
||||
package static var image_one: Image {
|
||||
Image("image_one")
|
||||
Image("image_one", bundle: Bundle.module)
|
||||
}
|
||||
|
||||
package static var image_two: Image {
|
||||
Image("image_two")
|
||||
Image("image_two", bundle: Bundle.module)
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
@@ -48,13 +48,14 @@ final class ParsedImageTests: XCTestCase {
|
||||
let property = parsedImage.getImageProperty(
|
||||
isStatic: false,
|
||||
isSwiftUI: false,
|
||||
visibility: .public
|
||||
visibility: .public,
|
||||
assetBundle: .main
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = """
|
||||
public var \(imageName): UIImage {
|
||||
UIImage(named: "\(imageName)")!
|
||||
UIImage(named: "\(imageName)", in: Bundle.main, with: nil)!
|
||||
}
|
||||
"""
|
||||
|
||||
@@ -75,13 +76,14 @@ final class ParsedImageTests: XCTestCase {
|
||||
let property = parsedImage.getImageProperty(
|
||||
isStatic: true,
|
||||
isSwiftUI: false,
|
||||
visibility: .internal
|
||||
visibility: .internal,
|
||||
assetBundle: .module
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = """
|
||||
internal static var \(imageName): UIImage {
|
||||
UIImage(named: "\(imageName)")!
|
||||
UIImage(named: "\(imageName)", in: Bundle.module, with: nil)!
|
||||
}
|
||||
"""
|
||||
|
||||
@@ -102,13 +104,14 @@ final class ParsedImageTests: XCTestCase {
|
||||
let property = parsedImage.getImageProperty(
|
||||
isStatic: false,
|
||||
isSwiftUI: true,
|
||||
visibility: .private
|
||||
visibility: .private,
|
||||
assetBundle: .main
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = """
|
||||
private var \(imageName): Image {
|
||||
Image("\(imageName)")
|
||||
Image("\(imageName)", bundle: Bundle.main)
|
||||
}
|
||||
"""
|
||||
|
||||
@@ -129,13 +132,14 @@ final class ParsedImageTests: XCTestCase {
|
||||
let property = parsedImage.getImageProperty(
|
||||
isStatic: true,
|
||||
isSwiftUI: true,
|
||||
visibility: .package
|
||||
visibility: .package,
|
||||
assetBundle: .module
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = """
|
||||
package static var \(imageName): Image {
|
||||
Image("\(imageName)")
|
||||
Image("\(imageName)", bundle: Bundle.module)
|
||||
}
|
||||
"""
|
||||
|
||||
|
@@ -94,9 +94,24 @@ final class DefinitionTests: XCTestCase {
|
||||
]
|
||||
|
||||
// When
|
||||
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .public)
|
||||
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en", visibility: .public)
|
||||
let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us", visibility: .public)
|
||||
let propertyFr = definition.getNSLocalizedStringProperty(
|
||||
forLang: "fr",
|
||||
isStatic: false,
|
||||
visibility: .public,
|
||||
assetBundle: .main
|
||||
)
|
||||
let propertyEn = definition.getNSLocalizedStringProperty(
|
||||
forLang: "en",
|
||||
isStatic: false,
|
||||
visibility: .public,
|
||||
assetBundle: .main
|
||||
)
|
||||
let propertyEnUs = definition.getNSLocalizedStringProperty(
|
||||
forLang: "en-us",
|
||||
isStatic: false,
|
||||
visibility: .public,
|
||||
assetBundle: .main
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectFr = """
|
||||
@@ -149,9 +164,24 @@ final class DefinitionTests: XCTestCase {
|
||||
]
|
||||
|
||||
// When
|
||||
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .private)
|
||||
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en", visibility: .private)
|
||||
let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us", visibility: .private)
|
||||
let propertyFr = definition.getNSLocalizedStringProperty(
|
||||
forLang: "fr",
|
||||
isStatic: false,
|
||||
visibility: .private,
|
||||
assetBundle: .main
|
||||
)
|
||||
let propertyEn = definition.getNSLocalizedStringProperty(
|
||||
forLang: "en",
|
||||
isStatic: false,
|
||||
visibility: .private,
|
||||
assetBundle: .main
|
||||
)
|
||||
let propertyEnUs = definition.getNSLocalizedStringProperty(
|
||||
forLang: "en-us",
|
||||
isStatic: false,
|
||||
visibility: .private,
|
||||
assetBundle: .main
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectFr = """
|
||||
@@ -203,9 +233,24 @@ final class DefinitionTests: XCTestCase {
|
||||
]
|
||||
|
||||
// When
|
||||
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .public)
|
||||
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en", visibility: .public)
|
||||
let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us", visibility: .public)
|
||||
let propertyFr = definition.getNSLocalizedStringProperty(
|
||||
forLang: "fr",
|
||||
isStatic: false,
|
||||
visibility: .public,
|
||||
assetBundle: .main
|
||||
)
|
||||
let propertyEn = definition.getNSLocalizedStringProperty(
|
||||
forLang: "en",
|
||||
isStatic: false,
|
||||
visibility: .public,
|
||||
assetBundle: .main
|
||||
)
|
||||
let propertyEnUs = definition.getNSLocalizedStringProperty(
|
||||
forLang: "en-us",
|
||||
isStatic: false,
|
||||
visibility: .public,
|
||||
assetBundle: .main
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectFr = """
|
||||
@@ -246,7 +291,7 @@ final class DefinitionTests: XCTestCase {
|
||||
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||
}
|
||||
|
||||
// MARK: - getNSLocalizedStringStaticProperty
|
||||
// MARK: - getNSLocalizedStringProperty - static
|
||||
|
||||
func testGeneratedNSLocalizedStringStaticProperty() {
|
||||
// Given
|
||||
@@ -260,9 +305,24 @@ final class DefinitionTests: XCTestCase {
|
||||
]
|
||||
|
||||
// When
|
||||
let propertyFr = definition.getNSLocalizedStringStaticProperty(forLang: "fr", visibility: .public)
|
||||
let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en", visibility: .public)
|
||||
let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us", visibility: .public)
|
||||
let propertyFr = definition.getNSLocalizedStringProperty(
|
||||
forLang: "fr",
|
||||
isStatic: true,
|
||||
visibility: .public,
|
||||
assetBundle: .main
|
||||
)
|
||||
let propertyEn = definition.getNSLocalizedStringProperty(
|
||||
forLang: "en",
|
||||
isStatic: true,
|
||||
visibility: .public,
|
||||
assetBundle: .main
|
||||
)
|
||||
let propertyEnUs = definition.getNSLocalizedStringProperty(
|
||||
forLang: "en-us",
|
||||
isStatic: true,
|
||||
visibility: .public,
|
||||
assetBundle: .main
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectFr = """
|
||||
@@ -315,9 +375,24 @@ final class DefinitionTests: XCTestCase {
|
||||
]
|
||||
|
||||
// When
|
||||
let propertyFr = definition.getNSLocalizedStringStaticProperty(forLang: "fr", visibility: .internal)
|
||||
let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en", visibility: .internal)
|
||||
let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us", visibility: .internal)
|
||||
let propertyFr = definition.getNSLocalizedStringProperty(
|
||||
forLang: "fr",
|
||||
isStatic: true,
|
||||
visibility: .internal,
|
||||
assetBundle: .main
|
||||
)
|
||||
let propertyEn = definition.getNSLocalizedStringProperty(
|
||||
forLang: "en",
|
||||
isStatic: true,
|
||||
visibility: .internal,
|
||||
assetBundle: .main
|
||||
)
|
||||
let propertyEnUs = definition.getNSLocalizedStringProperty(
|
||||
forLang: "en-us",
|
||||
isStatic: true,
|
||||
visibility: .internal,
|
||||
assetBundle: .main
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectFr = """
|
||||
@@ -369,9 +444,24 @@ final class DefinitionTests: XCTestCase {
|
||||
]
|
||||
|
||||
// When
|
||||
let propertyFr = definition.getNSLocalizedStringStaticProperty(forLang: "fr", visibility: .internal)
|
||||
let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en", visibility: .internal)
|
||||
let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us", visibility: .internal)
|
||||
let propertyFr = definition.getNSLocalizedStringProperty(
|
||||
forLang: "fr",
|
||||
isStatic: true,
|
||||
visibility: .internal,
|
||||
assetBundle: .main
|
||||
)
|
||||
let propertyEn = definition.getNSLocalizedStringProperty(
|
||||
forLang: "en",
|
||||
isStatic: true,
|
||||
visibility: .internal,
|
||||
assetBundle: .main
|
||||
)
|
||||
let propertyEnUs = definition.getNSLocalizedStringProperty(
|
||||
forLang: "en-us",
|
||||
isStatic: true,
|
||||
visibility: .internal,
|
||||
assetBundle: .main
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectFr = """
|
||||
@@ -422,7 +512,12 @@ final class DefinitionTests: XCTestCase {
|
||||
]
|
||||
|
||||
// When
|
||||
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .internal)
|
||||
let propertyFr = definition.getNSLocalizedStringProperty(
|
||||
forLang: "fr",
|
||||
isStatic: false,
|
||||
visibility: .internal,
|
||||
assetBundle: .main
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectFr = """
|
||||
@@ -458,7 +553,12 @@ final class DefinitionTests: XCTestCase {
|
||||
]
|
||||
|
||||
// When
|
||||
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .private)
|
||||
let propertyFr = definition.getNSLocalizedStringProperty(
|
||||
forLang: "fr",
|
||||
isStatic: false,
|
||||
visibility: .private,
|
||||
assetBundle: .main
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectFr = """
|
||||
@@ -495,8 +595,18 @@ final class DefinitionTests: XCTestCase {
|
||||
]
|
||||
|
||||
// When
|
||||
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .public)
|
||||
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en", visibility: .public)
|
||||
let propertyFr = definition.getNSLocalizedStringProperty(
|
||||
forLang: "fr",
|
||||
isStatic: false,
|
||||
visibility: .public,
|
||||
assetBundle: .main
|
||||
)
|
||||
let propertyEn = definition.getNSLocalizedStringProperty(
|
||||
forLang: "en",
|
||||
isStatic: false,
|
||||
visibility: .public,
|
||||
assetBundle: .main
|
||||
)
|
||||
|
||||
let expectFr = """
|
||||
/// Translation in fr :
|
||||
@@ -556,9 +666,21 @@ final class DefinitionTests: XCTestCase {
|
||||
]
|
||||
|
||||
// When
|
||||
let propertyFr = definition.getProperty(forLang: "fr", visibility: .public)
|
||||
let propertyEn = definition.getProperty(forLang: "en", visibility: .public)
|
||||
let propertyEnUs = definition.getProperty(forLang: "en-us", visibility: .public)
|
||||
let propertyFr = definition.getProperty(
|
||||
forLang: "fr",
|
||||
visibility: .public,
|
||||
isStatic: false
|
||||
)
|
||||
let propertyEn = definition.getProperty(
|
||||
forLang: "en",
|
||||
visibility: .public,
|
||||
isStatic: false
|
||||
)
|
||||
let propertyEnUs = definition.getProperty(
|
||||
forLang: "en-us",
|
||||
visibility: .public,
|
||||
isStatic: false
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectFr = """
|
||||
@@ -611,9 +733,21 @@ final class DefinitionTests: XCTestCase {
|
||||
]
|
||||
|
||||
// When
|
||||
let propertyFr = definition.getProperty(forLang: "fr", visibility: .package)
|
||||
let propertyEn = definition.getProperty(forLang: "en", visibility: .package)
|
||||
let propertyEnUs = definition.getProperty(forLang: "en-us", visibility: .package)
|
||||
let propertyFr = definition.getProperty(
|
||||
forLang: "fr",
|
||||
visibility: .package,
|
||||
isStatic: false
|
||||
)
|
||||
let propertyEn = definition.getProperty(
|
||||
forLang: "en",
|
||||
visibility: .package,
|
||||
isStatic: false
|
||||
)
|
||||
let propertyEnUs = definition.getProperty(
|
||||
forLang: "en-us",
|
||||
visibility: .package,
|
||||
isStatic: false
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectFr = """
|
||||
@@ -665,9 +799,21 @@ final class DefinitionTests: XCTestCase {
|
||||
]
|
||||
|
||||
// When
|
||||
let propertyFr = definition.getProperty(forLang: "fr", visibility: .private)
|
||||
let propertyEn = definition.getProperty(forLang: "en", visibility: .private)
|
||||
let propertyEnUs = definition.getProperty(forLang: "en-us", visibility: .private)
|
||||
let propertyFr = definition.getProperty(
|
||||
forLang: "fr",
|
||||
visibility: .private,
|
||||
isStatic: false
|
||||
)
|
||||
let propertyEn = definition.getProperty(
|
||||
forLang: "en",
|
||||
visibility: .private,
|
||||
isStatic: false
|
||||
)
|
||||
let propertyEnUs = definition.getProperty(
|
||||
forLang: "en-us",
|
||||
visibility: .private,
|
||||
isStatic: false
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectFr = """
|
||||
@@ -722,9 +868,21 @@ final class DefinitionTests: XCTestCase {
|
||||
]
|
||||
|
||||
// When
|
||||
let propertyFr = definition.getStaticProperty(forLang: "fr", visibility: .internal)
|
||||
let propertyEn = definition.getStaticProperty(forLang: "en", visibility: .internal)
|
||||
let propertyEnUs = definition.getStaticProperty(forLang: "en-us", visibility: .internal)
|
||||
let propertyFr = definition.getProperty(
|
||||
forLang: "fr",
|
||||
visibility: .internal,
|
||||
isStatic: true
|
||||
)
|
||||
let propertyEn = definition.getProperty(
|
||||
forLang: "en",
|
||||
visibility: .internal,
|
||||
isStatic: true
|
||||
)
|
||||
let propertyEnUs = definition.getProperty(
|
||||
forLang: "en-us",
|
||||
visibility: .internal,
|
||||
isStatic: true
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectFr = """
|
||||
@@ -777,9 +935,21 @@ final class DefinitionTests: XCTestCase {
|
||||
]
|
||||
|
||||
// When
|
||||
let propertyFr = definition.getStaticProperty(forLang: "fr", visibility: .internal)
|
||||
let propertyEn = definition.getStaticProperty(forLang: "en", visibility: .internal)
|
||||
let propertyEnUs = definition.getStaticProperty(forLang: "en-us", visibility: .internal)
|
||||
let propertyFr = definition.getProperty(
|
||||
forLang: "fr",
|
||||
visibility: .internal,
|
||||
isStatic: true
|
||||
)
|
||||
let propertyEn = definition.getProperty(
|
||||
forLang: "en",
|
||||
visibility: .internal,
|
||||
isStatic: true
|
||||
)
|
||||
let propertyEnUs = definition.getProperty(
|
||||
forLang: "en-us",
|
||||
visibility: .internal,
|
||||
isStatic: true
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectFr = """
|
||||
@@ -831,9 +1001,21 @@ final class DefinitionTests: XCTestCase {
|
||||
]
|
||||
|
||||
// When
|
||||
let propertyFr = definition.getStaticProperty(forLang: "fr", visibility: .internal)
|
||||
let propertyEn = definition.getStaticProperty(forLang: "en", visibility: .internal)
|
||||
let propertyEnUs = definition.getStaticProperty(forLang: "en-us", visibility: .internal)
|
||||
let propertyFr = definition.getProperty(
|
||||
forLang: "fr",
|
||||
visibility: .internal,
|
||||
isStatic: true
|
||||
)
|
||||
let propertyEn = definition.getProperty(
|
||||
forLang: "en",
|
||||
visibility: .internal,
|
||||
isStatic: true
|
||||
)
|
||||
let propertyEnUs = definition.getProperty(
|
||||
forLang: "en-us",
|
||||
visibility: .internal,
|
||||
isStatic: true
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectFr = """
|
||||
|
@@ -11,7 +11,7 @@ import ToolCore
|
||||
extension StringsFileGeneratorTests {
|
||||
|
||||
static func getExtensionContentExpectation(
|
||||
staticVar: Bool,
|
||||
isStatic: Bool,
|
||||
s1DefOneFr: String = "Section Un - Definition Un",
|
||||
s1DefOneComment: String = "",
|
||||
s1DefTwoFr: String = "Section Un - Definition Deux",
|
||||
@@ -20,7 +20,8 @@ extension StringsFileGeneratorTests {
|
||||
s2DefOneComment: String = "",
|
||||
s2DefTwoFr: String = "Section Deux - Definition Deux",
|
||||
s2DefTwoComment: String = "",
|
||||
visibility: ExtensionVisibility = .internal
|
||||
visibility: ExtensionVisibility = .internal,
|
||||
assetBundle: AssetBundle = .main
|
||||
) -> String {
|
||||
"""
|
||||
// Generated by ResgenSwift.Strings.Stringium \(ResgenSwiftVersion)
|
||||
@@ -54,8 +55,8 @@ extension StringsFileGeneratorTests {
|
||||
///
|
||||
/// Comment :
|
||||
/// \(s1DefOneComment.isEmpty ? "No comment" : s1DefOneComment)
|
||||
\(visibility) \(staticVar ? "static " : "")var s1_def_one: String {
|
||||
NSLocalizedString("s1_def_one", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Un - Definition Un", comment: "\(s1DefOneComment)")
|
||||
\(visibility) \(isStatic ? "static " : "")var s1_def_one: String {
|
||||
NSLocalizedString("s1_def_one", tableName: kStringsFileName, bundle: Bundle.\(assetBundle), value: "Section Un - Definition Un", comment: "\(s1DefOneComment)")
|
||||
}
|
||||
|
||||
/// Translation in fr :
|
||||
@@ -63,8 +64,8 @@ extension StringsFileGeneratorTests {
|
||||
///
|
||||
/// Comment :
|
||||
/// \(s1DefTwoComment.isEmpty ? "No comment" : s1DefTwoComment)
|
||||
\(visibility) \(staticVar ? "static " : "")var s1_def_two: String {
|
||||
NSLocalizedString("s1_def_two", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Un - Definition Deux", comment: "\(s1DefTwoComment)")
|
||||
\(visibility) \(isStatic ? "static " : "")var s1_def_two: String {
|
||||
NSLocalizedString("s1_def_two", tableName: kStringsFileName, bundle: Bundle.\(assetBundle), value: "Section Un - Definition Deux", comment: "\(s1DefTwoComment)")
|
||||
}
|
||||
|
||||
// MARK: - section_two
|
||||
@@ -74,8 +75,8 @@ extension StringsFileGeneratorTests {
|
||||
///
|
||||
/// Comment :
|
||||
/// \(s2DefOneComment.isEmpty ? "No comment" : s2DefOneComment)
|
||||
\(visibility) \(staticVar ? "static " : "")var s2_def_one: String {
|
||||
NSLocalizedString("s2_def_one", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Deux - Definition Un", comment: "\(s2DefOneComment)")
|
||||
\(visibility) \(isStatic ? "static " : "")var s2_def_one: String {
|
||||
NSLocalizedString("s2_def_one", tableName: kStringsFileName, bundle: Bundle.\(assetBundle), value: "Section Deux - Definition Un", comment: "\(s2DefOneComment)")
|
||||
}
|
||||
|
||||
/// Translation in fr :
|
||||
@@ -83,8 +84,8 @@ extension StringsFileGeneratorTests {
|
||||
///
|
||||
/// Comment :
|
||||
/// \(s2DefTwoComment.isEmpty ? "No comment" : s2DefTwoComment)
|
||||
\(visibility) \(staticVar ? "static " : "")var s2_def_two: String {
|
||||
NSLocalizedString("s2_def_two", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Deux - Definition Deux", comment: "\(s2DefTwoComment)")
|
||||
\(visibility) \(isStatic ? "static " : "")var s2_def_two: String {
|
||||
NSLocalizedString("s2_def_two", tableName: kStringsFileName, bundle: Bundle.\(assetBundle), value: "Section Deux - Definition Deux", comment: "\(s2DefTwoComment)")
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
@@ -377,16 +377,17 @@ final class StringsFileGeneratorTests: XCTestCase {
|
||||
sections: [sectionOne, sectionTwo],
|
||||
defaultLang: "fr",
|
||||
tags: ["ios", "iosonly", "notranslation"],
|
||||
staticVar: false,
|
||||
isStatic: false,
|
||||
inputFilename: "myInputFilename",
|
||||
extensionName: "GenStrings",
|
||||
extensionSuffix: "strings",
|
||||
visibility: .internal
|
||||
visibility: .internal,
|
||||
assetBundle: .main
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = Self.getExtensionContentExpectation(
|
||||
staticVar: false
|
||||
isStatic: false
|
||||
)
|
||||
|
||||
if extensionContent != expect {
|
||||
@@ -411,16 +412,17 @@ final class StringsFileGeneratorTests: XCTestCase {
|
||||
sections: [sectionOne, sectionTwo],
|
||||
defaultLang: "fr",
|
||||
tags: ["ios", "iosonly", "notranslation"],
|
||||
staticVar: false,
|
||||
isStatic: false,
|
||||
inputFilename: "myInputFilename",
|
||||
extensionName: "GenStrings",
|
||||
extensionSuffix: "strings",
|
||||
visibility: .public
|
||||
visibility: .public,
|
||||
assetBundle: .main
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = Self.getExtensionContentExpectation(
|
||||
staticVar: false,
|
||||
isStatic: false,
|
||||
s1DefOneComment: "This is a comment",
|
||||
s1DefTwoComment: "This is a comment",
|
||||
s2DefOneComment: "This is a comment",
|
||||
@@ -435,7 +437,7 @@ final class StringsFileGeneratorTests: XCTestCase {
|
||||
}
|
||||
|
||||
// MARK: - Extension Content Static
|
||||
func testGeneratedExtensionContentWithStaticVar() {
|
||||
func testGeneratedExtensionContentWithIsStatic() {
|
||||
// Given
|
||||
let sectionOne = Section.Mock.getSectionOne()
|
||||
let sectionTwo = Section.Mock.getSectionTwo()
|
||||
@@ -445,17 +447,19 @@ final class StringsFileGeneratorTests: XCTestCase {
|
||||
sections: [sectionOne, sectionTwo],
|
||||
defaultLang: "fr",
|
||||
tags: ["ios", "iosonly", "notranslation"],
|
||||
staticVar: true,
|
||||
isStatic: true,
|
||||
inputFilename: "myInputFilename",
|
||||
extensionName: "GenStrings",
|
||||
extensionSuffix: "strings",
|
||||
visibility: .package
|
||||
visibility: .package,
|
||||
assetBundle: .module
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = Self.getExtensionContentExpectation(
|
||||
staticVar: true,
|
||||
visibility: .package
|
||||
isStatic: true,
|
||||
visibility: .package,
|
||||
assetBundle: .module
|
||||
)
|
||||
|
||||
if extensionContent != expect {
|
||||
@@ -464,7 +468,7 @@ final class StringsFileGeneratorTests: XCTestCase {
|
||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||
}
|
||||
|
||||
func testGeneratedExtensionContentWithStaticVarWithComment() {
|
||||
func testGeneratedExtensionContentWithIsStaticWithComment() {
|
||||
// Given
|
||||
let sectionOne = Section.Mock.getSectionOne(
|
||||
defOneComment: "This is a comment",
|
||||
@@ -480,21 +484,23 @@ final class StringsFileGeneratorTests: XCTestCase {
|
||||
sections: [sectionOne, sectionTwo],
|
||||
defaultLang: "fr",
|
||||
tags: ["ios", "iosonly", "notranslation"],
|
||||
staticVar: true,
|
||||
isStatic: true,
|
||||
inputFilename: "myInputFilename",
|
||||
extensionName: "GenStrings",
|
||||
extensionSuffix: "strings",
|
||||
visibility: .internal
|
||||
visibility: .internal,
|
||||
assetBundle: .module
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = Self.getExtensionContentExpectation(
|
||||
staticVar: true,
|
||||
isStatic: true,
|
||||
s1DefOneComment: "This is a comment",
|
||||
s1DefTwoComment: "This is a comment",
|
||||
s2DefOneComment: "This is a comment",
|
||||
s2DefTwoComment: "This is a comment",
|
||||
visibility: .internal
|
||||
visibility: .internal,
|
||||
assetBundle: .module
|
||||
)
|
||||
|
||||
if extensionContent != expect {
|
||||
|
@@ -49,7 +49,7 @@ final class TagsGeneratorTests: XCTestCase {
|
||||
sections: [sectionOne, sectionTwo, sectionThree],
|
||||
lang: "ium",
|
||||
tags: ["ios", "iosonly"],
|
||||
staticVar: false,
|
||||
isStatic: false,
|
||||
extensionName: "GenTags",
|
||||
visibility: .public
|
||||
)
|
||||
|
Reference in New Issue
Block a user